Name to be passed to the generated files. {{name}}
and {{Name}}
inside contents and file names will be replaced
accordingly.
Template files to use as input. You may provide multiple files, each of which can be a relative or absolute path, or a glob pattern for multiple file matching easily.
Path to output to. If createSubFolder
is true
, the subfolder will be created inside this path.
May also be a FileResponseHandler which returns a new output path to override the default one.
Whether to create subfolder with the input name.
When true
, you may also use subFolderNameHelper to determine a pre-process helper on
the directory name.
Add custom data to the templates. By default, only your app name is included as {{name}}
and {{Name}}
.
This can be any object that will be usable by Handlebars.
Enable to override output files, even if they already exist.
You may supply a function to this option, which can take the arguments (fullPath, baseDir, baseName)
and returns
a string, to return a dynamic path for each file.
May also be a FileResponseHandler which returns a boolean value per file.
Suppress output logs (Same as verbose: 0
or verbose: LogLevel.None
)
Determine amount of logs to display.
The values are: 0 (none) | 1 (debug) | 2 (info) | 3 (warn) | 4 (error)
. The provided level will display messages
of the same level or higher.
Don't emit files. This is good for testing your scaffolds and making sure they don't fail, without having to write actual file contents or create directories.
Additional helpers to add to the template parser. Provide an object whose keys are the name of the function to add, and the value is the helper function itself. The signature of helpers is as follows:
(text: string, ...args: any[]) => string
A full example might be:
Scaffold({
//...
helpers: {
upperKebabCase: (text) => kebabCase(text).toUpperCase()
}
})
Which will allow:
{{ upperKebabCase "my value" }}
To transform to:
MY-VALUE
See DefaultHelpers for a list of all the built-in available helpers.
Simple Scaffold uses Handlebars.js, so all the syntax from there is supported. See their docs for more information.
Default transformer to apply to subfolder name when using createSubFolder: true
. Can be one of the default
capitalization helpers, or a custom one you provide to helpers
. Defaults to undefined
, which means no
transformation is done.
This callback runs right before content is being written to the disk. If you supply this function, you may return a string that represents the final content of your file, you may process the content as you see fit. For example, you may run formatters on a file, fix output in edge-cases not supported by helpers or data, etc.
If the return value of this function is undefined
, the original content will be used.
The original template after token replacement
The original template before token replacement
The final output path of the processed file
The final output of the file
contents-only, after further modifications - or undefined
to use the original content (i.e. content.toString()
)
Generated using TypeDoc
The config object for defining a scaffolding group.
https://github.com/chenasraf/simple-scaffold#readme
DefaultHelpers
CaseHelpers
DateHelpers