-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·32 lines (31 loc) · 1.38 KB
/
index.js
File metadata and controls
executable file
·32 lines (31 loc) · 1.38 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
#! /usr/bin/env node
var exec = require('child_process').exec;
var fs = require('fs');
// console.log(process.argv.slice(2)[0]);https://overreact.herokuapp.com
var projectName = process.argv.slice(2)[0].split('-')[0];
var append = 0;
function unzipIt(project, counter){
fs.stat(`./${project}`, function(err, stats) {
if(!stats) {
return exec(
//initiates a curl request to OverReact server for the requested zip file
//then unzips the file
//the unzipped file is nested, so move all of the grandchildren into the root folder and delete the nested folder
//delete the zip and echo
`curl -O https://overreact.herokuapp.com/zips/${process.argv.slice(2)[0]}.zip &&
unzip -qq -d ./${project} ${process.argv.slice(2)[0]}.zip &&
mv ./${project}/*/* ${project} &&
rm -rf ./${project}/${project} &&
rm -rf ${process.argv.slice(2)[0]}.zip &&
echo cd into ${project}${counter <= 0 ? '.' : ', your project name was taken in the cwd, thus the appended number.'} If you requested a starter kit, run "npm install" then "npm run start-dev", then visit your site at localhost:3000. Enjoy!;`, function(err, stdout) {
console.log(stdout);
})
// console.log(process.cwd());
} else {
counter++;
project = projectName + counter;
unzipIt(project, counter);
}
});
}
unzipIt(projectName, append);