0.5.0 • Published 8 years ago
files-generator v0.5.0
Files Generator
A tool to generate bunch of files, using different kinds of content definition and sources
Install
npm i files-generatorBasic usage
const generate = require('files-generator')();
generate({
'path/to/file': 'file content',
'path/to/file2': generate.use('other file content')
});
generate.on('finish', event => {
console.log(event.success); // ["path/to/file", "path/to/file2"]
})Documentation
generateGenerate
Create a generate function using the defined options
Parameters
optionsobject? An object containing the generate function options. (optional, default{})options.eventDatastring Each time that generate will emit an event, the event handler will receive as first argument an event object with a data key containing this eventData option. (optional, defaultundefined)options.writeFilefunction? The function which will be used to create files and/or directories. (optional, defaultdefaultWriteFile)options.encodingstring The encoding to use when writing files. (optional, default'utf-8')options.cwdstring The cwd used if you try to generate some relative paths. Must be an absolute path. (optional, defaultprocess.cwd())
Returns generate A generate function which uses by default the options provided as generateGenerate parameters
generate
Generate files from different kinds of inputs
Parameters
generateConfigGenerateConfig The generate config contains all the file paths to generate.optionsobject This options object can be used to overide some options defined in the generateGenerate function. (optional, default{})options.eventData(optional, default_eventData)options.writeFile(optional, default_writeFile)options.encoding(optional, default_encoding)options.cwd(optional, default_cwd)
Returns undefined
License
files-generator is released under MIT. Copyright (c) 2017-present Alexis Tessier