strips a pattern from the source template name to its final name. Useful
when templates include behavioral configuration files such as:
package.json and .gitignore. In such cases, use __package.json or
__.gitignore as the template name instead.
Implementation to support common variables when any template is written
with the _writeTemplates method.
perform filename interpolation by replacing {key} with respective values
and /^__/ automatically be applied.
relative name of file.
interpolation variables
filter templates scanned from the template directory
the template source relative to sourceRoot
false will omit the path
Write templates into destination
source directory to scan
interpolation object properties
flag to write recursively
Specify arguments for the generator. Generally preferred in the constructor.
Arguments are assigned by name to the this.options hash.
See documentation for
more information.
Argument name
Argument configuration
this.argument('prefix', {
type: String,
description: 'A prefix for the generated code',
required: false,
default: '',
});
// read the argument
const prefix = this.options.prefix;
Receives a list of components and an options object to install through bower.
The installation will automatically run during the run loop install phase.
Components to install
Options to pass to dargs as arguments
Options to pass child_process.spawn.
Resolved if install successful, rejected otherwise
Add a subgenerator run loop. Methods will be executed in parallel following the standard yeoman run loop. Note that options.parent will be automatically assigned as the generator from which the method is called. Options are also inherited from the parent generator.
subgenerator name registered in the GeneratorEnv
options passed to the subgenerator instance
Runs npm and bower, in sequence, in the generated directory and prints a
message to let the user know.
Resolved if install successful, rejected otherwise
Receives a list of packages and an options object to install through npm.
The installation will automatically run during the run loop install phase.
Packages to install
Options to pass to dargs as arguments
Options to pass child_process.spawn.
Resolved if install successful, rejected otherwise
Specify options for the generator. Generally preferred in teh constructor.
Options are assigned by camelCase name to the this.options hash.
See documentation for
more information.
Option name
Option configuration
this.option('language', {
alias: 'l',
type: String,
description: 'specify output language',
default: 'JavaScript',
});
// read the option
const language = this.options.language;
Prompt for user input based on inquirer
prompt question configurations
Combine package manager cmd line arguments and run the install command.
During the install step, every command will be scheduled to run once, on the
run loop. This means you can use Promise.then to log information, but don't
return it or mix it with this.async as it'll dead lock the process.
Which package manager to use
Packages to install. Use an empty string for npm install
Options to pass to dargs as arguments
Options to pass child_process.spawn. ref
https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
Resolved if install successful, rejected otherwise
Receives a list of packages and an options object to install through npm.
The installation will automatically run during the run loop install phase.
Packages to install
Options to pass to dargs as arguments
Options to pass child_process.spawn.
Resolved if install successful, rejected otherwise
Abstract generator from which others are based
Yeoman