What is yeoman-environment?
The yeoman-environment npm package is a robust tool for managing the lifecycle and execution of Yeoman generators. It provides a powerful API to handle the environment in which generators run, making it easier to create, run, and manage generators.
What are yeoman-environment's main functionalities?
Creating a new environment
This feature allows you to create a new Yeoman environment instance. The environment is responsible for running the generators and managing their lifecycle.
const yeoman = require('yeoman-environment');
const env = yeoman.createEnv();
Registering a generator
This feature allows you to register a generator with a specific namespace. The generator can then be run using this namespace.
env.register(require.resolve('generator-name'), 'namespace');
Running a generator
This feature allows you to run a registered generator by its namespace. You can also pass options and a callback function to be executed once the generator has finished running.
env.run('namespace', options, done);
Resolving a generator
This feature allows you to resolve a generator by its namespace. This can be useful if you need to interact with the generator programmatically.
const Generator = env.get('namespace');
Other packages similar to yeoman-environment
yeoman-generator
The yeoman-generator package provides the base class for creating Yeoman generators. While yeoman-environment focuses on managing the environment and lifecycle of generators, yeoman-generator is used to define the generators themselves.
plop
Plop is a micro-generator framework that allows you to create and run generators. It is similar to yeoman-environment in that it helps manage the lifecycle of generators, but it is generally considered to be simpler and more lightweight.
hygen
Hygen is a code generator tool that focuses on being fast and easy to use. It provides a different approach to code generation compared to yeoman-environment, with a focus on simplicity and speed.
Yeoman Environment
Handles the lifecycle and bootstrapping of generators in a specific environment
It provides a high-level API to discover, create and run generators, as well as further tuning of where and how a generator is resolved.
Install
$ npm install yeoman-environment
Usage
Full documentation available here.
const yeoman = require('yeoman-environment');
const env = yeoman.createEnv();
env.lookup(() => {
env.run('angular', {'skip-install': true}, err => {
console.log('done');
});
});
For advance usage, see our API documentation.
License
BSD-2-Clause © Yeoman