New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

kopy

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kopy

Gracefully copy a directory and render templates.

  • 2.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

kopy

NPM version NPM downloads Build Status

Gracefully copy a directory and render templates.

Why is this useful?

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

Install

$ npm install --save kopy

Usage

const copy = require('kopy')

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

Template Syntax

Templates could use handlebars syntax or any template engine in consolidate.js

API

copy(src, dest, options)

src

Type: string
Required: true

Source directory. Could be a relative or absolute path.

dest

Type: string
Required: true

Destination directory.

options
engine

Type: string
Default: handlebars

All template engines that're supported by consolidate.js

clean

Type: boolean
Default: true

Whether to clean destination directory before writing to it.

cwd

Type: string
Default: process.cwd()

Current working directory.

data

Type: object
Default: {}

The data to render templates in source directory.

skipInterpolation

Type: string | Array<string> | function
Default: undefined (we skip all binary files by default)

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

It could also be a function, whose first arg is file path and second arg is file content, eg. we want to exclude all .js files:

copy(src, dest, {
  skipInterpolation(file, content) {
    return /\.js$/.test(file)
  }
})

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

egoistian.com · GitHub @egoist · Twitter @rem_rin_rin

Keywords

FAQs

Package last updated on 26 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc