Skip to content

Commit

Permalink
fix(all generators): ensure defaults to 'input' type prompts' are ind…
Browse files Browse the repository at this point in the history
…eed strings
  • Loading branch information
cueedee committed May 12, 2015
1 parent 4657f19 commit 345be4a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var AppGenerator = generators.Base.extend(
type: 'input'
, name: 'packageName'
, message: 'What is the package name of this webapp?'
, default: this.packageName
, default: youtil.definedToString( this.packageName )
, validate: youtil.isNpmName
}
, {
Expand All @@ -95,15 +95,15 @@ var AppGenerator = generators.Base.extend(
type: 'input'
, name: 'authorName'
, message: 'What is your name?'
, default: this.user.git.name()
, default: youtil.definedToString( this.user.git.name() )
, validate: youtil.isNonBlank
, filter: clean
}
, {
type: 'input'
, name: 'authorEmail'
, message: 'What is your email address?'
, default: this.user.git.email()
, default: youtil.definedToString( this.user.git.email() )
, validate: youtil.isNonBlank
, filter: _.trim
}
Expand Down
2 changes: 1 addition & 1 deletion generators/collection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var CollectionGenerator = generators.Base.extend(
type: 'input'
, name: 'collectionName'
, message: 'What is the name of this collection you so desire?'
, default: this.collectionName
, default: youtil.definedToString( this.collectionName )
, validate: youtil.isIdentifier
, filter: function ( value )
{
Expand Down
4 changes: 2 additions & 2 deletions generators/model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var ModelGenerator = generators.Base.extend(
type: 'input'
, name: 'modelName'
, message: 'What is the name of this model you so desire?'
, default: this.options.modelName
, default: youtil.definedToString( this.options.modelName )
, validate: youtil.isIdentifier
, filter: function ( value )
{
Expand All @@ -96,7 +96,7 @@ var ModelGenerator = generators.Base.extend(
type: 'input'
, name: 'description'
, message: 'What is the purpose (description) of this model?'
, default: this.options.description
, default: youtil.definedToString( this.options.description )
, validate: youtil.isNonBlank
, filter: youtil.sentencify
}
Expand Down
2 changes: 1 addition & 1 deletion generators/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var ViewGenerator = generators.Base.extend(
type: 'input'
, name: 'viewName'
, message: 'What is the name of this view you so desire?'
, default: this.viewName
, default: youtil.definedToString( this.viewName )
, validate: youtil.isIdentifier
, filter: function ( value )
{
Expand Down
7 changes: 6 additions & 1 deletion lib/youtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ var capitalize = require( 'underscore.string/capitalize' )

module.exports =
{
isIdentifier: function ( value )
definedToString: function ( value )
{
return (( value == null ) ? value : '' + value );
}

, isIdentifier: function ( value )
{
return /^[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*$/.test(( '' + value ).trim() );
}
Expand Down

0 comments on commit 345be4a

Please sign in to comment.