env/resolver

Methods

static alias(match, value)

Get or create an alias.

Alias allows the get() and lookup() methods to search in alternate filepath for a given namespaces. It's used for example to map generator-* npm package to their namespace equivalent (without the generator- prefix), or to default a single namespace like angular to angular:app or angular: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
match String | RegExp
value String
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 level node_module path. They can be installed globally or locally.

Parameters:
Name Type Attributes Description
List Array

of search paths

options Object <optional>
Properties
Name Type Attributes Default Description
packagePatterns boolean <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
options boolean | Object <optional>
Properties
Name Type Attributes Default Description
localOnly boolean <optional>
false

Set true to skip lookups of globally-installed generators.

filterPaths boolean <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.js file placed inside an npm package.

Defaults lookups are:

  • ./
  • generators/
  • lib/generators/

So this index file node_modules/generator-dummy/lib/generators/yo/index.js would be registered as dummy:yo generator.

Parameters:
Name Type Attributes Description
options boolean | Object <optional>
Properties
Name Type Attributes Default Description
localOnly boolean <optional>
false

Set true to skip lookups of globally-installed generators.

packagePaths string | Array <optional>

Paths to look for generators.

npmPaths string | Array <optional>

Repository paths to look for generators packages.

filePatterns string | Array <optional>
'*\/index.js'

File pattern to look for.

packagePatterns string | Array <optional>
'generator-*'

Package pattern to look for.

singleResult boolean <optional>
false

Set true to stop lookup on the first match.

globbyDeep Number <optional>

Deep option to be passed to globby.

cb function

Callback called once the lookup is done. Take err as first parameter.

Returns:
Array.<Object> -

List of generators