graceful-copy: 打造你自己的 yeoman 或者 vue-cli

1,048 阅读1分钟

Gracefully copy a directory with templates.

Why is this useful?

This could be used to build a scaffolding tool like yeoman or vue-cli.

Install

$ npm install --save graceful-copy

const copy = require('graceful-copy')

copy({
  src: './template',
  dest: './dest',
  data: {
    foo: 'bar'
  }
}, err => {
  if (err) return console.log(err)

  console.log('done!')
})

Templates

Templates could use handlebars syntax.

API

options: object

src: string

Source directory. Could be a relative or absolute path.

dest: string

Destination directory.

clean: boolean

Whether to clean destination directory before writing to it. Defaults to true.

cwd: string

Current working directory. Defaults to process.cwd().

data: object

The data to render templates in source directory.

callback: function


graceful-copy © EGOIST, Released under the MIT License.
Authored and maintained by EGOIST with help from contributors (list).

egoistian.com · GitHub @egoist · Twitter @rem_rin_rin