npm

Need private packages and team management tools?Check out npm Orgs. »

struc

1.0.1 • Public • Published

struc Travis build AppVeyor build

Create file/dir structures from plain js objects on disk

Most useful in testing while combined with tempy.

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. Will be created if doesn't exist, otherwise must be an empty directory.

structure

Type: Object

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

License

MIT © nikersify

install

npm i struc

Downloadsweekly downloads

0

version

1.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability