forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall-blueprint.js
42 lines (36 loc) · 1.33 KB
/
install-blueprint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
var Blueprint = require('../models/blueprint');
var Task = require('../models/task');
var Promise = require('../ext/promise');
var temp = require('temp');
var childProcess = require('child_process');
var path = require('path');
var merge = require('lodash/merge');
var mkdir = Promise.denodeify(temp.mkdir);
var exec = Promise.denodeify(childProcess.exec);
module.exports = Task.extend({
run: function(options) {
var cwd = process.cwd();
var name = options.rawName;
var blueprintOption = options.blueprint;
// If we're in a dry run, pretend we changed directories.
// Pretending we cd'd avoids prompts in the actual current directory.
var fakeCwd = path.join(cwd, name);
var target = options.dryRun ? fakeCwd : cwd;
var installOptions = {
target: target,
entity: { name: name },
ui: this.ui,
project: this.project,
dryRun: options.dryRun,
targetFiles: options.targetFiles,
rawArgs: options.rawArgs
};
installOptions = merge(installOptions, options || {});
var blueprintName = blueprintOption || 'app';
var blueprint = Blueprint.lookup(blueprintName, {
paths: this.project.blueprintLookupPaths()
});
return blueprint.install(installOptions);
}
});