You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

template-copy

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

template-copy

Tiny scaffolding engine

1.1.2
latest
npmnpm
Version published
Weekly downloads
3.8K
-13.14%
Maintainers
1
Weekly downloads
 
Created
Source

template-copy

Tiny scaffolding engine

Like cp, but with Lodash templates

Install

npm i template-copy

Usage

const t = require('template-copy');

t('index.html templates/ ~/.config/templates/ava/ test/');
  .catch((err) => {
    console.log('ERR', err);
  })
  .then(() => {
    console.log('done');
  });

Description

File copy is done using Streams, with lodash.template parsing files if they have template placeholders {{ ... }}.

Handlebars template are executed in the context of the following object:

Object.assign({}, env, opts)

// where `env` and `opts` have the following structure

{
  env: {
    PATH: '...',
    ...
  },

  opts: {
    debug: true,
    name: 'Foobar'
  }
}

The templates context is a merged version of various sources, with the following order of precedence:

  • opts - Command line flags as parsed by minimist
  • env - process.env variables begining with hcp_
  • prompts - Generated prompts, see below

Prompts

Handlebars templates can have any number of placeholders. Variables are either available in the context object, or automatically prompted for the user to enter a value.

Skipping a prompt is then available with --name Value.

To enable it, inquirer must be installed and available in node_modules.

npm i inquirer -D

If not installed, prompts are not generated.

JSON

JSON files are merged together with destination, if it already exists.

  • hcp - CLI command power by template-copy

Keywords

scaffold

FAQs

Package last updated on 28 May 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