1.0.11 • Published 6 years ago

json-file-structure v1.0.11

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
6 years ago

Getting started

"json-file-structure" was created to create file & directory structures from a JSON definition

Example

	const JSONtoFiles = require('json-file-structure);

	let destination = 'dist';

	let data = [
		{
			name: "index.html",  // required
			content: "<h1 id=\"header\">Home Page</h1>"
		},{
			name: "about.html",  // required
			content: "<h1 id=\"header\">About Page</h1>"
		},{
			name: "assets",  // required
			children: [ // required for directories
				{
					name: "projects.json", // required
					content: "{\"projects\":[]}"
				},
				{
					name: "images", // required
					children: [] // required for directories
				}
			]
		}
	]


	JSONtoFiles(destination,data);
Output
- dist/
	- index.html
	- about.html
	- assets/
		- projects.json
		- images/

Types

json-file-structure can create both directories and files. Below are the required fields for each.

Directories (folders)

Directories are created when an object has a children key with a value type of array. This array can be empty but it MUST exist for a directory to be created. You can nest directories

empty directory
{
	name: "images", // required
	children: [] // required
}

Files

Files are created if the object has a name. However content is optional.

empty file
{
	name: "test.txt", // required
}
1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago