Mixin: env/resolver

env/resolver

Source:

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
Source:
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) → {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 Description
List Array

of search paths

Source:
Returns:

List of the generator modules path

Type
Array

(static) getNpmPaths() → {Array}

Get the npm lookup directories (node_modules/)

Source:
Returns:

lookup paths

Type
Array

(static) lookup(cb)

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 Description
cb function

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

Source: