-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.js
93 lines (79 loc) · 2.14 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
85
86
87
88
89
90
91
92
93
'use strict';
var yeoman = require('yeoman-generator');
module.exports = yeoman.generators.Base.extend({
initializing: function () {
this.pkg = require('../package.json');
},
welcome: function () {
this.log(this.yeoman);
},
prompting: function () {
var cb = this.async();
var prompts = [{
name: 'name',
message: 'Module Name'
}, {
name: 'description',
message: 'Description',
default: 'The best commonjs module ever.'
}, {
name: 'homepage',
message: 'Homepage'
}, {
name: 'license',
message: 'License',
default: 'MIT'
}, {
name: 'githubUsername',
message: 'GitHub username',
store: true
}, {
name: 'authorName',
message: 'Author\'s Name',
store: true
}, {
name: 'authorEmail',
message: 'Author\'s Email',
store: true
}, {
name: 'authorUrl',
message: 'Author\'s Homepage',
store: true
}];
this.currentYear = (new Date()).getFullYear();
this.prompt(prompts, function (props) {
this.slugname = this._.slugify(props.name);
this.camelname = this._.camelize(props.name);
this.repoUrl = 'https://github.com/' + props.githubUsername + '/' + this.slugname;
if (!props.homepage) {
props.homepage = this.repoUrl;
}
this.props = props;
cb();
}.bind(this));
},
source: function () {
this.mkdir('src');
this.copy('src/jshintrc', 'src/.jshintrc');
this.template('src/name.js', 'src/' + this.slugname + '.js');
},
test: function () {
this.mkdir('test');
this.template('test/name_test.js', 'test/' + this.slugname + '_test.js');
},
projectfiles: function () {
this.copy('editorconfig', '.editorconfig');
this.copy('jshintrc', '.jshintrc');
this.copy('gitignore', '.gitignore');
this.template('readme.md');
this.template('Gruntfile.js');
this.template('_package.json', 'package.json');
this.copy('contributing.md', 'contributing.md');
},
install: function () {
this.installDependencies({
bower: false,
skipInstall: this.options['skip-install']
});
}
});