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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    1
  • 1.0.0
    0

Package Sidebar

Install

npm i struc

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • nikersify