-
Notifications
You must be signed in to change notification settings - Fork 2
/
cli.js
57 lines (50 loc) · 1.63 KB
/
cli.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env node
'use strict';
var vorpal = require('vorpal')(),
taskManager = require('./lib/task-manager.js'),
configController = require('./lib/config-controller.js'),
profileManager = require('./lib/profile-manager.js'),
chalk = require('chalk');
var cli = {
init: function() {
var conf = configController.check() !== false ? require(configController.path) : false;
var projectName = conf !== false ? chalk.green('~' + conf.projectName) : '';
var missingConfMsg = "You should have a 'gulpit-conf.js' file in this directory!" +
"\nEnding process.";
// Watch Command
vorpal
.command('watch', 'Watch for source modification and rebuild after save.')
.option('--css', 'Watch only for CSS change.')
.option('--js', 'Watch only for JS change.')
.option('--prod', 'Use prod profile.')
.action(function(args) {
if (configController.check() !== false) {
// If config file is present
taskManager.init('watch', args, profileManager.selector(args));
} else {
this.log(chalk.red.bold(missingConfMsg));
vorpal.ui.cancel();
}
});
// Build Command
vorpal
.command('build', 'Build the project.')
.option('--css', 'Build only the CSS.')
.option('--js', 'Build only the JS.')
.option('--prod', 'Use prod profile.')
.action(function(args) {
if (configController.check() !== false) {
// If config file is present
taskManager.init('build', args, profileManager.selector(args));
} else {
this.log(chalk.red.bold(missingConfMsg));
vorpal.ui.cancel();
}
});
// CLI prefix
vorpal
.delimiter('gulpit' + projectName + '$')
.show();
}
};
cli.init();