
Simple scaffolding utility, inspired by Sao.js
Installation
$ npm install scaffe
Programmatic Usage
const scaffe = require("scaffe")
async function build(){
...
try {
await scaffe.generate(templateDir, outDir, { overwrite: true, variables: { name: "app" } });
} catch(err) {
console.log(err)
}
scaffe.generate(templateDir, outDir, { overwrite: true, variables: { name: "app" }).catch((err) => {
console.log(err);
})
scaffe.generate(templateDir, outDir, variables, (err) => {
console.log(err);
})
}
More Info
The only available function in Scaffe is generate
which takes arguments as
following in order.
templateDir
: It's the path to the template directory.
outDir
: The output directory
config
: An Object with two props {boolean} overwrite (by default false)
, {object} variables
Template directory can have two types of files
starts with _
: this file will be evaluated as an ejs file
doesn't starts with _
: this type of files will be copied as it is to the output directory.
So we can use variables in our template files in ejs format.
A use case,
{
"name": "<%= appName %>"
}
variables
in 3rd argument (i.e. config) will contain all variable values that
need to be passed on to be processed by ejs.