Last active
March 23, 2016 23:48
-
-
Save nicoespeon/908c25b772cee491ab56 to your computer and use it in GitHub Desktop.
Blog - Plop — a micro-generator to ease your daily life - prompts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {trimRight, isEmpty} from "lodash"; | |
const ensurePlural = ( text ) => trimRight( text, "s" ) + "s"; | |
const isNotEmptyFor = ( name ) => { | |
return ( value ) => { | |
if ( isEmpty( value ) ) return name + " is required"; | |
return true; | |
} | |
} | |
module.exports = ( plop ) => { | |
plop.setGenerator( "module", { | |
// … | |
prompts: [ | |
{ | |
type: "input", | |
name: "name", | |
message: "What is your module name?", | |
validate: isNotEmptyFor( "name" ), | |
filter: ensurePlural | |
} | |
], | |
// … | |
} ); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment