graceful-copy

Gracefully copy a directory with templates.

Usage no npm install needed!

<script type="module">
  import gracefulCopy from 'https://cdn.skypack.dev/graceful-copy';
</script>

README

graceful-copy

NPM version NPM downloads Build Status

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

Usage

const copy = require('graceful-copy')

copy('./template', './dest', {
  data: {
    foo: 'bar'
  }
}).then(files => {
  console.log(files) // array of filenames in './dest'
}).catch(err => {
  console.log(err.stack)
})

Templates

Templates could use handlebars syntax.

API

copy(src, dest, options)

src: string

Source directory. Could be a relative or absolute path.

dest: string

Destination directory.

options: object

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.

skipInterpolation: string | string[]

Patterns used to skip interpolation, eg: ./foo*/bar-*.js


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