I've been creating a lot of tests for yeoman generators lately, and I'm having trouble understanding the purpose of the withGenerators() helper method.
The example given:
var angular = new RunContext('../../app');
angular.withGenerators([
'../../common',
'../../controller',
'../../main',
[helpers.createDummyGenerator(), 'testacular:app']
]);
The function itself:
RunContext.prototype.withGenerators = function (dependencies) {
assert(_.isArray(dependencies), 'dependencies should be an array');
this.dependencies = this.dependencies.concat(dependencies);
return this;
};
I see that the function adds an array of dependencies to the Run Context object, with each item in the array being a path to a dependent generator.
What are these paths used for?
When and why would I need to use this method?
In the example given, is calling angular.withGenerators([...]) identical to calling yo angular, yo angular:common, yo angular:controller, and so on from the command line, or does it somehow simulate or modify calls to composeWith() in the actual generator?
What is the difference between running withGenerators() in the tests, and calling composeWith() from the generator itself?
Aucun commentaire:
Enregistrer un commentaire