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 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) → {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.

Returns:
Array.<Object> -

List of generators