-
Notifications
You must be signed in to change notification settings - Fork 247
/
Copy pathgrunt
executable file
·72 lines (64 loc) · 1.87 KB
/
grunt
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env node
'use strict';
process.title = 'grunt';
var Liftup = require('liftup');
var v8flags = require('v8flags');
var extensions = require('interpret').jsVariants;
var nopt = require('nopt');
var gruntOptions = require('grunt-known-options');
var completion = require('../lib/completion.js');
var info = require('../lib/info.js');
var pkg = require('../package.json');
// Parse `gruntOptions` into a form that nopt can handle.
var aliases = {};
var known = {};
Object.keys(gruntOptions).forEach(function(key) {
var short = gruntOptions[key].short;
if (short) {
aliases[short] = '--' + key;
}
known[key] = gruntOptions[key].type;
});
// Parse them and return an options object.
var options = nopt(known, aliases, process.argv, 2);
if ('completion' in options) {
completion.print(options.completion);
} else if (options.version) {
console.log('grunt-cli v' + pkg.version);
}
v8flags(function (err, v8flags) {
var Grunt = new Liftup({
name: 'grunt',
configName: 'Gruntfile',
// Support a number of languages based on file extension
extensions: extensions,
// Flags that are v8 flags will be loaded into node instead of Gruntfile
v8flags: v8flags
});
Grunt.prepare({
cwd: options.base,
configPath: options.gruntfile,
require: options.require,
preload: options.preload,
verbose: options.verbose
}, function (env) {
Grunt.execute(env, function(env) {
var tasks = options.argv.remain;
delete options.argv;
// No grunt install found!
if (!env.modulePath) {
if (options.version) {
process.exit();
}
if (options.help) {
info.help();
}
info.fatal('Unable to find local grunt.', 99);
} else {
options.gruntfile = env.configPath;
var grunt = require(env.modulePath);
grunt.tasks(tasks, options);
}
});
});
});