This repository has been archived by the owner on Jan 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
84 lines (69 loc) · 2.29 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 util = require('util');
var exec = require('child_process').exec;
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var PlaygroundGenerator = module.exports = function PlaygroundGenerator(args, options) {
yeoman.generators.Base.apply(this, arguments);
this.on('end', function installDependencies() {
this.installDependencies({
skipInstall: options['skip-install']
});
});
};
util.inherits(PlaygroundGenerator, yeoman.generators.Base);
PlaygroundGenerator.prototype.promptForConfiguration = function promptForConfiguration() {
var done = this.async();
var prompts = [{
type: 'confirm',
name: 'includeNormalize',
message: 'Would you like to include normalize.css?',
default: true
}, {
type: 'confirm',
name: 'includeJQuery',
message: 'Would you like to include jQuery?',
default: true
}];
this.prompt(prompts, function processAnswers(answers) {
this.includeNormalize = answers.includeNormalize;
this.includeJQuery = answers.includeJQuery;
done();
}.bind(this));
};
PlaygroundGenerator.prototype.createProjectFiles = function createProjectFiles() {
this.template('_index.html', 'index.html', this);
this.copy('js/app.js');
this.copy('css/style.css');
this.copy('Gruntfile.js');
this.copy('package.json');
this.template('_bower.json', 'bower.json', this);
this.copy('gitignore', '.gitignore');
this.copy('gitattributes', '.gitattributes');
};
PlaygroundGenerator.prototype.gitCommit = function gitCommit() {
var done = this.async();
this.log('\n\nInitializing Git repository. If this fail, try running ' +
chalk.yellow.bold('git init') +
' and make a first commit manually');
var async = require('async');
async.series([
function (taskDone) {
exec('git init', taskDone);
},
function (taskDone) {
exec('git add . --all', taskDone);
},
function (taskDone) {
exec('git commit -m "Created playground"', taskDone);
}
], function (err) {
console.log(err);
if (err === 127) {
this.log('Could not find the ' + chalk.yellow.bold('git') + ' command. Make sure Git is installed on this machine');
return;
}
this.log(chalk.green('complete') + ' Git repository has been setup');
done();
}.bind(this));
};