-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
59 lines (53 loc) · 2.17 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
59
#!/usr/bin/env node
var program = require('commander');
var spawn = require('child_process').spawn;
program
.arguments('<ProjectName>')
.option('-s, --ssh', 'Use ssh instead of https')
.action(function (ProjectName) {
console.log('Creating project: ', ProjectName);
var command = 'git'
var args, args2;
if (program.ssh)
args = ['clone', 'https://github.com/sahat/hackathon-starter.git', ProjectName]
else
args = ['clone', '[email protected]:sahat/hackathon-starter.git', ProjectName]
name = ProjectName;
var p = spawn('git', args);
p.stdout.on('data', (data) => {
console.log(data.toString());
});
p.stderr.on('data', (data) => {
console.log(data.toString());
});
p.on('close', (code) => {
if (code == 0) {
console.log('');
console.log('hackathon-starter successfuly cloned in to: ', ProjectName);
console.log('');
console.log('');
console.log('The next step is to install the npm dependencies of your project. You can do this by executing the following two commands:');
console.log('');
console.log(' cd', ProjectName);
console.log(' npm install');
console.log('');
console.log('See https://github.com/sahat/hackathon-starter for additional information to get started.');
console.log('');
} else {
console.log('git clone existed with error code: ', code.toString());
}
});
})
.version('3.0.1', '-v, --version')
.parse(process.argv);
if (typeof name === 'undefined') {
console.log('');
console.error('Error: Project name was not specified.');
console.log('');
console.log('Try: hackathon-starter <ProjectName> [-ssh]');
console.log('Where <ProjectName> is the name of the project that you would like to initiate using Hackathon Starter.');
console.log('');
console.log(' -s, --ssh Use ssh instead of https to clone from github.');
console.log('');
process.exit(1);
}