scaffold-helper
v1.2.0
Published
Helps with generating files and file structures
Downloads
27
Maintainers
Readme
scaffold-helper
Copies files and folders from source directory to destination directory (all directories recursively or just files from the source directory) with template style from template-file
Installation
$ npm i scaffold-helper --save
or
$ yarn add scaffold-helper
Usage
In this section you will see two example usages. One example copies the complete source directory tree to the destination and replaces all variables within the templates. The other example will only copy files within the source directory to the destination directory and replaces all variables within the templates.
The given source directory tree:
.
+-- source/directory/
|
+-- dir-1
| |
| +-- file-2
|
+-- dir-2
| |
| +-- file-3
|
+-- template-1
The given template-1
:
My name is {{name}} and I am {{age}} years old.
example one
The scaffold-helper
module example WITH copying recursive all files and directories:
const scaffold = require('scaffold-helper'); // import scaffold from 'scaffold-helper';
// if we set onlyFiles to false it copies the complete directory tree
// from 'source/directory' to 'destination/directory'
// excluding 'dir-1'
scaffold(
{
source: 'source/directory',
destination: 'destination/directory',
onlyFiles: false,
exclude: ['dir-1'], // add as many directories as you want to the array
},
{
name: 'Cliff',
age: '25',
},
);
The example above will copy the source directory tree to the 'destination/directory' and replace all variables within all files
The destination directory tree:
.
+-- destination/directory/
|
+-- dir-2
| |
| +-- file-3
|
+-- template-1
The template-1 with filled variables:
My name is Cliff and I am 25 years old.
example two
The scaffold-helper
module example WITHOUT copying recursive all files and directories:
const scaffold = require('scaffold-helper'); // import scaffold from 'scaffold-helper';
// if we set onlyFiles to true it copies only the files
// within 'source/directory' to 'destination/directory'
scaffold(
{
source: 'source/directory',
destination: 'destination/directory',
onlyFiles: true
},
{
name: 'Cliff',
age: '25',
},
);
The example above will only copy the files within the source directory and will not recursively copy all directories and files.
The destination directory tree:
.
+-- destination/directory/
|
+-- template-1
The template-1 with filled variables:
My name is Cliff and I am 25 years old.
LICENSE
MIT © Cliff Pyles