Skip to content

Instantly share code, notes, and snippets.

@kenwheeler
Last active November 30, 2016 21:52
Show Gist options
  • Save kenwheeler/7a043557ac2c911b76f65233b9fae26f to your computer and use it in GitHub Desktop.
Save kenwheeler/7a043557ac2c911b76f65233b9fae26f to your computer and use it in GitHub Desktop.
"use strict";
module.exports = {
destination: {
default: function (data) {
return data.packageName;
}
},
prompts: {
packageName: {
message: "Package / GitHub project name (e.g., 'whiz-bang-component')",
validate: function (val) {
return /^([a-z0-9]+\-?)+$/.test(val.trim()) || "Must be lower + dash-cased string";
}
},
enableRedux: {
type: "confirm",
message: "Do you want to include Redux?",
},
},
derived: {
componentPath: function (data, cb) { cb(null, data.packageName); },
componentName: function (data, cb) {
// PascalCase (with first character capitalized).
var name = data.packageName
.replace(/^\s+|\s+$/g, "")
.replace(/(^|[-_ ])+(.)/g, function (match, first, second) {
return second.toUpperCase();
});
cb(null, name);
}
}
};
// Directory
// app/
// components/
// {{enableRedux}}container.js
// config/
// {{enableRedux}}redux/
// reducers/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment