-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·51 lines (39 loc) · 1.22 KB
/
index.js
File metadata and controls
executable file
·51 lines (39 loc) · 1.22 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
#!/usr/bin/env node
const async = require('async-collection')
const { exec } = require('child_process')
const format = require('format-json-stream')
const fs = require('fs')
const path = require('path')
const pump = require('pump')
const lib = require('./lib')
const cmd = process.argv[2]
const name = process.argv[3]
exec('npm --version', (err, stdout, stderr) => {
if (err) throw new Error(err.message)
})
if (!cmd || cmd !== 'new' || !name) {
throw new Error('Usage: choo-bandwagon new my-cool-app')
}
const dest = path.resolve('./', name)
async.waterfall([
lib.checkPath(dest),
lib.copyAssets()
], (err) => {
if (err) throw new Error(err)
const packageDest = path.resolve(dest, 'package.json')
pump(lib.packager(name), format(), fs.createWriteStream(packageDest),
err => {
if (err) throw new Error(err)
console.log(`You just joined a choo bandwagon at ${dest}.`)
const bar = lib.progress()
bar.start()
const installer = Promise.all([
lib.npm.install(dest),
lib.npm.installDev(dest)
])
installer
.then(() => console.log('...All packages successfully installed.'))
.catch(err => console.error(err))
.then(() => bar.stop())
})
})