Skip to content

Instantly share code, notes, and snippets.

@nicoespeon
Last active March 23, 2016 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicoespeon/908c25b772cee491ab56 to your computer and use it in GitHub Desktop.
Save nicoespeon/908c25b772cee491ab56 to your computer and use it in GitHub Desktop.
Blog - Plop — a micro-generator to ease your daily life - prompts
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