1
私は最初のカスタムYeoman Generatorを使用しています。ジェネレータがpackage.jsonファイルを作成しているときにエラー_ is not defined
が発生しています。エラーがここ_は定義されていませんカスタム生成者
1| {
>> 2| "name": "<%= _.slugify(appName) %>",
3| "version": "0.0.1",
4| "description": "<%= appDescription %>",
5| "author": "<%= authorName %>",
を基準にしている私のindex.jsが
'use strict';
var _ = require('underscore.string');
var generators = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
module.exports = generators.Base.extend({
prompting: function() {
var done = this.async();
// Have Yeoman greet the user.
this.log(yosay(
'Welcome to the ' + chalk.red('\nSMS Boilerplate') + '\n generator!'
));
this.log(chalk.green(
'You\'ll also have the option to use Normalise-css and Modernizr.js \n'
));
this.prompt([{
type: 'input',
name: 'appName',
message: 'Your project name',
default: 'sms-project',
store: true
}, {
type: 'input',
name: 'appDescription',
message: 'Short description of the project...',
default: 'A new SMS project',
store: true
}, {
type: 'input',
name: 'gitUsername',
message: 'What\'s your Github username?',
store: true
}, {
type: 'input',
name: 'authorName',
message: 'What\'s your name (the author)?',
default: '',
store: true
}, {
type: 'confirm',
name: 'includeNormalize',
message: 'Would you like to include Normalize.css?',
default: true
}]).then(function(answers) {
this.props = answers;
this.log('app name', answers.appName);
done();
}.bind(this));
},
writing: {
// Copy the configuration files
config: function() {
this.fs.copyTpl(
this.templatePath('_package.json'),
this.destinationPath('package.json'),
{
appName: _.slugify(this.props.appName),
appDescription : this.props.appDescription,
authorName : this.props.authorName
}
);
this.fs.copyTpl(
this.templatePath('_bower.json'),
this.destinationPath('bower.json'),
{
appName: this.props.appName,
appDescription : this.props.appDescription,
authorName : this.props.authorName,
includeNormalize : this.props.includeNormalize
}
);
this.fs.copy(
this.templatePath('bowerrc'),
this.destinationPath('.bowerrc')
);
},
// Copy Application Files
app: function() {
this.fs.copy(
this.templatePath('scss/_style.scss'),
this.destinationPath('scss/style.scss')
);
this.fs.copy(
this.templatePath('css/_style.css'),
this.destinationPath('css/style.css')
);
this.fs.copy(
this.templatePath('js/_script.js'),
this.destinationPath('js/script.js')
);
this.fs.copyTpl(
this.templatePath('index.html'),
this.destinationPath('index.html'),
{
appName: this.props.appName,
appDescription : this.props.appDescription,
authorName : this.props.authorName
}
);
this.fs.copy(
this.templatePath('_Gruntfile.js'),
this.destinationPath('Gruntfile.js')
);
},
},
//Install Dependencies
install: function() {
this.installDependencies({
bower: true,
npm: true,
callback: function() {
this.spawnCommand('grunt', ['bowerBuild']);
}.bind(this)
});
},
});
を提出された私はヨーマンジェネレータV 0.23.0およびノードV 4.4.5 を使用しています任意の助けてくれてありがとう。