forked from DevExpress/devextreme-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (49 loc) · 1.52 KB
/
index.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
#!/usr/bin/env node
const args = require('minimist')(process.argv.slice(2), {
alias: { v: 'version' }
});
const commands = args['_'];
delete args['_'];
const themeBuilder = require('./commands/themebuider');
const application = require('./commands/application');
const devextremeConfig = require('./utility/devextreme-config');
const printHelp = require('./commands/help').printHelp;
const packageJson = require('./package.json');
process.on('unhandledRejection', (error) => {
console.log(error);
process.exit(1);
});
if(!commands.length) {
if(args.version) {
console.log(packageJson.version);
} else {
console.error('The DevExtreme command is not specified.');
printHelp();
}
process.exit();
}
if(args.help) {
printHelp(commands[0]);
process.exit();
}
const run = (commands, options) => {
if(application.isApplicationCommand(commands[0])) {
application.run(commands, options, devextremeConfig.read());
} else if(themeBuilder.isThemeBuilderCommand(commands[0])) {
options.command = commands[0];
themeBuilder.run(options);
} else {
console.error(`Command '${commands[0]}' does not exist.`);
}
};
if(commands[0] === 'build') {
const config = devextremeConfig.read();
if(config.build && config.build.commands) {
console.log('The DevExtreme build started');
config.build.commands.forEach(commandConfig => {
run([commandConfig.command], commandConfig.options);
});
}
} else {
run(commands, args);
}