1. copy-template-dir
High throughput template dir writes
copy-template-dir
Package: copy-template-dir
Created by: yoshuawuyts
Last modified: Mon, 13 Jun 2022 23:18:09 GMT
Version: 1.4.0
License: MIT
Downloads: 637,998
Repository: https://github.com/yoshuawuyts/copy-template-dir

Install

npm install copy-template-dir
yarn add copy-template-dir

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

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin