You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
unknown
0073d80258
|
2 years ago | |
---|---|---|
.. | ||
LICENSE | 2 years ago | |
README.md | 2 years ago | |
index.js | 2 years ago | |
package.json | 2 years ago |
README.md
copy-template-dir
High throughput template dir writes. Supports variable injection using the
mustache {{ }}
syntax.
Installation
$ npm install copy-template-dir
Usage
const copy = require('copy-template-dir')
const path = require('path.join')
const vars = { foo: 'bar' }
const inDir = path.join(process.cwd(), 'templates')
const outDir = path.join(process.cwd(), 'dist')
copy(inDir, outDir, vars, (err, createdFiles) => {
if (err) throw err
createdFiles.forEach(filePath => console.log(`Created ${filePath}`))
console.log('done!')
})
API
copyTemplateDir(templateDir, targetDir, vars, cb)
Copy a directory of files over to the target directory, and inject the files with variables. Takes the following arguments:
- templateDir: The directory that holds the templates. Filenames prepended
with a
_
will have it removed when copying. Dotfiles need to be prepended with a_
. Files and filenames are populated with variables using the{{varName}}
syntax. - targetDir: the output directory
- vars: An object with variables that are injected into the template files and file names.
- cb(err, createdFiles): A callback that is called on completion, with paths to created files if there were no errors.