generator-simple-less-site
Version:
Yeoman generator for creating a simple website using lessCSS and bootstrap
75 lines (61 loc) • 2 kB
JavaScript
'use strict';
var fs = require('fs');
var path = require('path');
var util = require('util');
var genUtils = require('../util.js');
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var wiredep = require('wiredep');
var SimpleLessGenerator = yeoman.generators.Base.extend({
init: function () {
this.argument('name', { type: String, required: false });
this.appname = this.name || path.basename(process.cwd());
this.appname = this._.camelize(this._.slugify(this._.humanize(this.appname)));
this.option('app-suffix', {
desc: 'Allow a custom suffix to be added to the module name',
type: String,
required: 'false'
});
this.scriptAppName = this.appname + genUtils.appName(this);
this.appPath = this.env.options.appPath;
this.pkg = require('../package.json');
this.filters = {};
},
info: function () {
this.log(this.yeoman);
this.log('Out of the box I create an simple LessCSS website.\n');
},
checkForConfig: function() {
var cb = this.async();
if(this.config.get('filters')) {
this.prompt([{
type: "confirm",
name: "skipConfig",
message: "Existing .yo-rc configuration found, would you like to use it?",
default: true,
}], function (answers) {
this.skipConfig = answers.skipConfig;
// NOTE: temp(?) fix for #403
if(typeof this.oauth==='undefined') {
var strategies = Object.keys(this.filters).filter(function(key) {
return key.match(/Auth$/) && key;
});
if(strategies.length) this.config.set('oauth', true);
}
cb();
}.bind(this));
} else {
cb();
}
},
generate: function() {
this.sourceRoot(path.join(__dirname, './templates'));
genUtils.processDirectory(this, '.', '.');
},
end: function() {
this.installDependencies({
skipInstall: this.options['skip-install']
});
}
});
module.exports = SimpleLessGenerator;