forked from mjackson/web-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.js
38 lines (30 loc) · 1001 Bytes
/
setup.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
const fs = require('fs')
const path = require('path')
const readline = require('readline')
const execSync = require('child_process').execSync
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
rl.question(`What is the name of your project? `, (projectName) => {
rl.close()
const workingDir = process.cwd()
const outputDir = path.resolve(workingDir, projectName)
const relativeDir = path.relative(workingDir, outputDir)
execSync(`git clone --depth 1 https://github.com/mjackson/web-starter ${outputDir}`)
fs.stat(outputDir, (error, stats) => {
if (error) {
console.error(error)
process.exit(1)
}
if (!stats.isDirectory()) {
console.error(`Failed to clone web-starter into ${outputDir}`)
process.exit(1)
}
process.chdir(outputDir)
execSync(`rm -rf .git app.json setup.js`)
process.chdir(workingDir)
console.log(`Created a new project in ./${relativeDir}`)
process.exit(0)
})
})