-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
75 lines (66 loc) · 1.75 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#! /usr/bin/env node
const packageName = require("./package.json").name;
const path = require("path");
const fs = require("fs");
const shell = require("shelljs");
const yargs = require("yargs");
const argv = yargs.argv;
const pwd = shell.pwd().toString();
const settings = require("./settings");
// yargs.version("1.1.0");
// Create add command
yargs.command({
command: "init",
describe: "Create a new config file",
builder: {
/*
body: {
describe: 'Note body',
demandOption: true,
type: 'string'
},
ignore:{
alias: 'i',
type: 'boolean'
}
*/
},
handler(argv) {
const src = `./node_modules/${packageName}/${
settings.defaultUserConfigFilename
}`;
const dest = `${settings.userConfigFilename}`;
const exists = fs.existsSync(dest);
if (!exists) {
shell.cp(src, dest);
console.log("hexact.json created");
} else {
console.log("hexact.json already exists! - delete it and try again");
}
}
});
yargs.command({
command: "*",
describe: "Perform default behaviour",
handler(argv) {
defaultCommand();
}
});
yargs.parse();
function defaultCommand() {
shell.env["DEPENDENT_STARTUP_PATH"] = pwd;
try {
const userConfig = require(path.join(pwd, settings.userConfigFilename)); // just access it to check existance!
const args = argv._.join(" ");
if (argv._.length > 0) {
shell.cd(`node_modules/${packageName}`);
shell.exec(`npm run gulp ${args}`);
} else {
console.log("No task specified!");
console.log("use: hexact local");
console.log("or : hexact dev deploy");
}
} catch (e) {
console.log("No hexac.json found, please run: 'hexac init' to create one");
}
}