copy-template-dir

High throughput template dir writes

MIT 11 个版本
安装
npm install copy-template-dir
yarn add copy-template-dir
pnpm add copy-template-dir
bun add copy-template-dir
README

copy-template-dir

NPM version build status Test coverage Downloads js-standard-style

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.

See Also

License

MIT

版本列表
1.4.0 2018-03-21
1.3.0 2016-08-10
1.2.1 2016-03-16
1.2.0 2015-12-21
1.1.0 2015-12-13
1.0.5 2015-11-26
1.0.4 2015-10-06
1.0.3 2015-10-04
1.0.2 2015-10-04
1.0.1 2015-10-03
1.0.0 2015-10-03