-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteractive.js
More file actions
76 lines (68 loc) · 1.69 KB
/
Copy pathinteractive.js
File metadata and controls
76 lines (68 loc) · 1.69 KB
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
76
const inquirer = require('inquirer');
const shell = require('shelljs')
//PUT THEM IN REVERSE ORDER BECAUSE OF THE INVERSED WHILE LATER
const DEV = false;
const react = [
"react-dom",
"react-i18next",
"react-router-redux",
"react-router",
"react-redux",
"redux",
"axios",
"i18next-xhr-backend",
"i18next",
"react"
]
const reactDev = [
"react-test-renderer",
"babel-jest",
"jest",
"eslint-plugin-react"
]
inquirer.prompt(
[
/* Pass your questions in here */
{
type: "list",
name: "js",
message: "What to install ?",
choices: [
"react",
]
}
])
.then((answers) => {
let libs, libsDev, cmd = "", cmdDev = "", pkg = "", pkgDev = ""
libs = react
libsDev = reactDev
//Do we want to write in our package.json ?
if (!DEV){
pkg = "-S "
pkgDev = "-D "
}
//install dependencies
let i = libs.length-1
while(i >= 0){
//Fucking yarn crash with shelljs, fallback on npm
if(i === libs.length -1)
cmd += `npm i ${pkg}`
cmd += libs[i] + " "
i--
}
//install devDependencies
let j = libsDev.length-1
while(j >= 0){
//Fucking yarn crash with shelljs, fallback on npm
if(j === libsDev.length -1)
cmdDev += `npm i ${pkgDev}`
cmdDev += libsDev[j] + " "
j--
}
console.log(cmd)
shell.exec(cmd)
console.log(cmdDev)
shell.exec(cmdDev)
shell.exec('mv '+ answers.js +' src')
}
);