-
Notifications
You must be signed in to change notification settings - Fork 9
/
cli.js
58 lines (53 loc) · 1.57 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
58
const fs = require("fs");
// const path = require("path");
// var colors = require('colors');
// var os = require('os');
//import path from "path";
var reco1 = require("./reco1");
var reco2 = require("./reco2");
const officeService = require("./office");
export function cli(args) {
officeService(args.slice(2)[0]);
//--react cmd
if (args[1].includes(".bin\\react") || args[1].includes(".bin/react")) {
let new_args = [];
new_args.push(args[0]);
new_args.push(args[1]);
new_args.push("react");
args.slice(2).forEach((arg) => {
new_args.push(arg);
});
args = new_args;
}
//fix to the new virsion (after v1.2.0 the react folder name it's "react-js")
if (fs.existsSync("./react"))
fs.renameSync(`./react`, `./react-js`, function (error, stdout, stderr) {
if (error) {
// reco1.setState({ error: true });
console.error("reco-cli-init-renameReactFolder ERROR : " + error);
return;
}
console.log(stdout);
});
if (fs.existsSync("./cordova") && fs.existsSync("./react-js")) {
reco1.constructor(args);
}
if (
(fs.existsSync("package.json") &&
!fs.existsSync("./cordova") &&
!fs.existsSync("./react-js")) ||
args.slice(2)[0] === "init" ||
args.slice(2)[0] === "version" ||
args.slice(2)[0] === "help"
) {
reco2.constructor(args);
} else {
console.log("");
console.log("");
console.log("");
console.log("it is not reco based project");
console.log("");
console.log('try to run => reco init com.myAppId "my app name"');
console.log("");
}
}