From 6a26fcf7e48aa4d1f4e67a5ec7cadacef6ff3cd6 Mon Sep 17 00:00:00 2001 From: Zewa Date: Wed, 25 Feb 2015 20:06:54 +0100 Subject: [PATCH] Upgraded Generator to use new Yo-API This modification should fix the bug mentioned in https://github.com/jquery-boilerplate/generator-jquery-boilerplate/issues/6 --- app/index.js | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/app/index.js b/app/index.js index e07c110..5ba35ff 100644 --- a/app/index.js +++ b/app/index.js @@ -1,29 +1,32 @@ var fs = require('fs'); var path = require('path'); var chalk = require('chalk'); +var generators = require('yeoman-generator'); -var Generator = module.exports = function() { - var prompts = []; - var files = this.expandFiles('**/*', { cwd: this.sourceRoot(), dot: true }); - var ignores = [ - '.git', - 'LICENSE', - 'README.md', - ]; +var Generator = module.exports = generators.Base.extend({ + init: function() { + var prompts = []; + var files = this.expandFiles('**/*', { cwd: this.sourceRoot(), dot: true }); + var ignores = [ + '.git', + 'LICENSE', + 'README.md', + ]; - this.package = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json'))); + this.package = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json'))); - this.log.writeln('Generating from ' + chalk.cyan('jQuery Boilerplate') + ' v' + chalk.cyan(this.package.version) + '...'); + this.log.writeln('Generating from ' + chalk.cyan('jQuery Boilerplate') + ' v' + chalk.cyan(this.package.version) + '...'); - files.forEach(function(file) { - if (ignores.indexOf(file) !== -1) { - return; - } + files.forEach(function(file) { + if (ignores.indexOf(file) !== -1) { + return; + } - this.copy(file, file); - }, this); + this.copy(file, file); + }, this); - this.config.save(); -}; + this.config.save(); + } +}); Generator.name = "jQuery Boilerplate";