-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreator.js
More file actions
56 lines (51 loc) · 1.45 KB
/
Copy pathcreator.js
File metadata and controls
56 lines (51 loc) · 1.45 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
// MODULES
const {
execSync
} = require('child_process');
const fs = require('fs')
// USER VALUES
const modules = process.argv.slice(3)
const directoryName = process.argv[2]
// CREATING AND CHANGING DIRECTORY
fs.mkdirSync(directoryName)
process.chdir(`./${directoryName}`) // === ./ IS COMPULSARY
// CREATING PACKAGE.JSON
execSync('npm init -y', (err, stdout, stderr) => {
// IF ERROR OCCURES
if (err) {
return console.error(err);
}
// IF NO ERROR
if (stdout) {
return console.log(`Created package.json\nnpm output =`, stdout);
}
})
// LOOPING THROUGH NPM MODULES ONLINE
for (let i = 0; i < modules.length; i++) {
// INSTALLING NPM MODULES
execSync(`npm install ${modules[i]}`, (err, stdout, stderr) => {
// IF ERROR OCCURES
if (err) {
console.error(err);
return ;
}
// IF SUCCESS
if (stdout) {
console.log(`Installed module ${module[i]}\nnpm output =`, stdout);
return;
}
});
}
// MAKING FILES DIRECTORIES
execSync('mkdir routeHandeling routes && touch .env server.js routeHandeling/routeHandle1.js routeHandeling/routeHandel2.js routes/getRoutes.js routes/postRoutes.js', (err, stdout, stderr) => {
// IF ERROR OCCURES
if (err) {
console.error(err);
return;
}
// IF SUCCESS
if (stdout) {
console.log(`Installed module ${module[i]}\nnpm output =`, stdout);
return;
}
})