-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·58 lines (52 loc) · 1.32 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env node
var inquirer = require('inquirer')
var map = require('map-limit')
var path = require('path')
module.exports = runEdits
function runEdits (root, opts, done) {
map([
require('./edits/readme'),
require('./edits/license'),
require('./edits/package'),
require('./edits/index'),
require('./edits/test'),
require('./edits/demo'),
require('./edits/gitignore')
], 1, function (fn, next) {
fn(root, opts, next)
}, done)
}
if (!module.parent) {
var pkg = {}
try {
pkg = require(process.cwd() + '/package.json')
} catch (e) {}
inquirer.prompt([{
type: 'input',
name: 'packageName',
message: 'Package name:',
default: pkg.name || path.basename(process.cwd())
}, {
type: 'input',
name: 'packageDescription',
message: 'Package description:',
default: pkg.description || ''
}, {
type: 'confirm',
name: 'hasDemo',
message: 'Include web demo:',
default: !!(pkg.scripts && pkg.scripts.start)
}, {
type: 'confirm',
name: 'hasTest',
message: 'Include tests:',
default: !!(pkg.scripts && pkg.scripts.test)
}]).then(function (responses) {
module.exports(process.cwd(), responses, function (err) {
if (err) throw err
})
}).catch(function (err) {
console.error(err.message)
console.error(err.stack)
})
}