Skip to content
/ struc Public

build file/directory structures from plain js objects

License

Notifications You must be signed in to change notification settings

rsify/struc

Repository files navigation

struc Travis build AppVeyor build

Create file/dir structures on disk from plain js objects

Install

$ npm install struc

Usage

The following input:

const struc = require('struc');

struc('path/', {
	'file': 'file contents',
	'directory': {
		'another-file': 'with stuff inside!',
		'empty-dir': {}
	}
});

...would place the following files/directories on disk:

path/file: "file contents"
path/directory/another-file: "with stuff inside"
path/directory/empty-dir/

API

struc([path], structure)

Returns the absolute resolved path.

path

Type: String
Default: tempy.directory()

Path to the target directory the structure will be placed inside of. The directory Will be created if doesn't exist, otherwise must be an empty directory.

structure

Type: Object

A file/directory representation, object keys represent paths, object values must be of type Object or String (Array isn't allowed). An Object represents a directory with its keys being other files/directories, while String represents a file with contents being the String itself.

License

MIT © nikersify

About

build file/directory structures from plain js objects

Resources

License

Stars

Watchers

Forks

Packages

No packages published