This repository has been archived by the owner on Oct 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
85 lines (76 loc) · 2.16 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
'use strict'
var toCase = require('to-case')
var extend = require('extend')
var parseAuthor = require('parse-author')
var Base = require('../base')
module.exports = Base.extend({
constructor: function () {
Base.apply(this, arguments)
this.option('codecov', {
type: Boolean,
required: false,
default: false,
desc: 'Include the codecov badge'
})
},
initializing: function () {
this.shouldSkipAll = this.options.yes
this.props = {
badges: ['npm', 'travis', this.options.codecov && 'codecov'].filter(Boolean)
}
},
prompting: {
badges: function () {
var done = this.async()
this.prompt({
type: 'checkbox',
name: 'badges',
message: 'Select the badges that you want in your README',
choices: [
{ name: 'npm' },
{ name: 'travis' },
{ name: 'codecov' },
{ name: 'david' },
{ name: 'downloads' }
],
default: this.props.badges,
when: !this.shouldSkipAll
}, function (answers) {
extend(this.props, answers)
done()
}.bind(this))
}
},
writing: function () {
var pkg = this.fs.readJSON(this.destinationPath('package.json'), {})
var authorInfo
if (pkg.author && typeof pkg.author === 'object') {
authorInfo = pkg.author
} else if (typeof pkg.author === 'string') {
authorInfo = parseAuthor(pkg.author)
} else {
authorInfo = {}
}
// get githubUsername from repository field
// assume for simplicity that the field has the form
//
// githubUsername/moduleName
//
var githubUsername = (pkg.repository || '').split('/')[0]
extend(this.props, {
name: authorInfo.name || '',
email: authorInfo.email || '',
website: authorInfo.url || '',
githubUsername: githubUsername,
moduleName: (pkg.name || this.appname),
moduleDescription: pkg.description || '',
moduleLicense: pkg.license || ''
})
this.props.camelModuleName = toCase.camel(this.props.moduleName)
this.fs.copyTpl(
this.templatePath('README.tpl'),
this.destinationPath('README.md'),
this.props
)
}
})