generator-es6app
Version:
Yeoman generator
68 lines (58 loc) • 2.15 kB
JavaScript
'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
module.exports = yeoman.generators.Base.extend({
initializing: function () {
this.pkg = require('../package.json');
},
prompting: function () {
var done = this.async();
// Have Yeoman greet the user.
this.log(yosay(
'Welcome to the stunning' + chalk.red(' Es6App ') + ' generator!'
));
var prompts = [{
type: 'input',
name: 'name',
message: 'Please provide your Project Name:',
default: this.appname
}];
this.prompt(prompts, function (props) {
this.name = props.name;
done();
}.bind(this));
},
writing: {
app: function () {
this.fs.copyTpl(this.templatePath('_package.json'),this.destinationPath('package.json'), {
appName: this.name
}
);
this.fs.copyTpl(this.templatePath('_bower.json'),this.destinationPath('bower.json'), {
appName: this.name
}
);
this.fs.copy(this.templatePath('_config.js'),this.destinationPath('config.js'));
this.fs.copy(this.templatePath('_gulpfile.js'),this.destinationPath('gulpfile.js'));
},
projectfiles: function () {
this.mkdir('src');
this.mkdir('dest');
this.fs.copy(this.templatePath('_main.js'), this.destinationPath('src/main.js'));
this.fs.copy(this.templatePath('editorconfig'), this.destinationPath('.editorconfig'));
this.fs.copy(this.templatePath('jshintrc'), this.destinationPath('.jshintrc'));
this.fs.copyTpl(this.templatePath('_index.html'), this.destinationPath('index.html'), {
appName: this.name
});
}
},
install: function () {
this.installDependencies({
skipInstall: this.options['skip-install']
});
},
end: function () {
this.spawnCommand('jspm', ['install', '-y']);
}
});