Methods
-
static alias(match, value)
-
Get or create an alias.
Alias allows the
get()andlookup()methods to search in alternate filepath for a given namespaces. It's used for example to mapgenerator-*npm package to their namespace equivalent (without the generator- prefix), or to default a single namespace likeangulartoangular:apporangular:all.Given a single argument, this method acts as a getter. When both name and value are provided, acts as a setter and registers that new alias.
If multiple alias are defined, then the replacement is recursive, replacing each alias in reverse order.
An alias can be a single String or a Regular Expression. The finding is done based on .match().
Parameters:
Name Type Description matchString | RegExp valueString Example
env.alias(/^([a-zA-Z0-9:\*]+)$/, 'generator-$1'); env.alias(/^([^:]+)$/, '$1:app'); env.alias(/^([^:]+)$/, '$1:all'); env.alias('foo'); // => generator-foo:all -
static findGeneratorsIn(List, optionsopt) → {Array}
-
Search npm for every available generators. Generators are npm packages who's name start with
generator-and who're placed in the top levelnode_modulepath. They can be installed globally or locally.Parameters:
Name Type Attributes Description ListArray of search paths
optionsObject <optional> Properties
Name Type Attributes Default Description packagePatternsboolean <optional> 'generator-*' Pattern pattern.
Returns:
Array -List of the generator modules path
- Deprecated:
-
- Yes
-
static getNpmPaths(optionsopt) → {Array}
-
Get the npm lookup directories (
node_modules/)Parameters:
Name Type Attributes Description optionsboolean | Object <optional> Properties
Name Type Attributes Default Description localOnlyboolean <optional> false Set true to skip lookups of globally-installed generators.
filterPathsboolean <optional> false Remove paths that don't ends with a supported path (don't touch at NODE_PATH paths).
Returns:
Array -lookup paths
- Deprecated:
-
- Yes
-
static lookup(optionsopt, cb) → {Array.<Object>}
-
Search for generators and their sub generators.
A generator is a
:lookup/:name/index.jsfile placed inside an npm package.Defaults lookups are:
- ./
- generators/
- lib/generators/
So this index file
node_modules/generator-dummy/lib/generators/yo/index.jswould be registered asdummy:yogenerator.Parameters:
Name Type Attributes Description optionsboolean | Object <optional> Properties
Name Type Attributes Default Description localOnlyboolean <optional> false Set true to skip lookups of globally-installed generators.
packagePathsstring | Array <optional> Paths to look for generators.
npmPathsstring | Array <optional> Repository paths to look for generators packages.
filePatternsstring | Array <optional> '*\/index.js' File pattern to look for.
packagePatternsstring | Array <optional> 'generator-*' Package pattern to look for.
singleResultboolean <optional> false Set true to stop lookup on the first match.
globbyDeepNumber <optional> Deep option to be passed to globby.
cbfunction Callback called once the lookup is done. Take err as first parameter.
Returns:
Array.<Object> -List of generators