-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.js
43 lines (35 loc) · 1.19 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
const spawn = require('child_process').spawn;
const fs = require('fs');
const ncp = require('ncp');
const inquirer = require('inquirer');
require('colors');
const args = process.argv;
const name = args[2];
if (!name) {
console.error('You must enter a name for your project. `sails-react-webpack ProjectName`'.yellow);
process.exit(0);
}
// CREATE THE DIRECTORY FOR THE PROJECT
console.log(`Creating new directory '${name}'...`.underline);
fs.mkdir(name, (fsError) => {
if (fsError && fsError.code === 'EEXIST') {
console.log('A directory with that name already exists. \nPlease try again with a different name.'.red);
process.exit(0);
}
// COPY THE FOLDER TEMPLATE TO THE NEW PROJECT
ncp(`${__dirname}/template`, `${process.cwd()}/${name}`, (cpError) => {
if (cpError) {
console.log(cpError);
process.exit(0);
}
console.log(`Successfully created new project '${name}'!`.green);
console.log();
console.log('Next Steps:'.blue);
console.log(` cd ${name}`);
console.log(` npm install`);
console.log();
console.log('npm start'.yellow);
console.log(' Starts both Sails and the Webpack Dev Server simultaneously');
console.log();
});
});