UNPKG

1.21 kBJavaScriptView Raw
1'use strict';
2
3var utils = require('./utils');
4
5/**
6 * Extend the generator being invoked with settings from the instance,
7 * but only if the generator is not the `default` generator.
8 *
9 * Also, note that this **does not add tasks** from the `default` generator
10 * onto the instance.
11 */
12
13module.exports = function(app, generator, ctx) {
14 var env = generator.env || {};
15 var alias = env.alias;
16
17 // update `cache.config`
18 var config = utils.merge({}, ctx || app.cache.config || app.pkg.get(app._name));
19 generator.set('cache.config', config);
20
21 // set options
22 utils.merge(generator.options, app.options);
23 utils.merge(generator.options, config);
24
25 // extend generator with settings from default
26 if (app.generators.hasOwnProperty('default') && alias !== 'default') {
27 var compose = generator
28 .compose(['default'])
29 .options();
30
31 if (typeof app.data === 'function') {
32 compose.data();
33 }
34
35 if (typeof app.pipeline === 'function') {
36 compose.pipeline();
37 }
38
39 if (typeof app.helper === 'function') {
40 compose.helpers();
41 compose.engines();
42 compose.views();
43 }
44
45 if (typeof app.question === 'function') {
46 compose.questions();
47 }
48 }
49};