generator-fresh
Version:
mad fresh boilerplate generator for yeoman
79 lines (61 loc) • 2.11 kB
JavaScript
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var FreshGenerator = module.exports = function FreshGenerator(args, options, config) {
yeoman.generators.Base.apply(this, arguments);
this.on('end', function () {
this.installDependencies({ skipInstall: options['skip-install'] });
});
this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};
util.inherits(FreshGenerator, yeoman.generators.Base);
FreshGenerator.prototype.askFor = function askFor() {
var cb = this.async();
// have Yeoman greet the user.
console.log(this.yeoman);
var prompts = [
{
type: 'confirm',
name: 'useGrunt',
message: 'Would you like to use Grunt for task running?'
}
];
this.prompt(prompts, function (props) {
// `props` is an object passed in containing the response values, named in
// accordance with the `name` property from your prompt object.
// this.projectName = props.projectName;
this.useGrunt = props.useGrunt;
cb();
}.bind(this));
};
FreshGenerator.prototype.app = function app() {
// Compass config directory
this.directory('config', 'config');
// Images
this.directory('img', 'img');
// JavaScripts
this.mkdir('js');
this.directory('js/vendor', 'js/vendor');
// Styles
this.directory('styles', 'styles');
// Process and copy templates with Lo-Dash
// this.template('_index.html', 'index.html');
// this.template('_package.json', 'package.json');
// Grunt
if (this.useGrunt) {
this.copy('Gruntfile.js', 'Gruntfile.js');
this.copy('package.json', 'package.json');
} else {
this.copy('_package.json', 'package.json');
}
};
FreshGenerator.prototype.projectfiles = function projectfiles() {
this.copy('.editorconfig', '.editorconfig');
this.copy('.jshintrc', '.jshintrc');
this.copy('.htaccess', '.htaccess');
this.copy('.gitignore', '.gitignore');
this.copy('crossdomain.xml', 'crossdomain.xml');
this.copy('robots.txt', 'robots.txt');
this.copy('index.html', 'index.html');
};