Skip to content

Instantly share code, notes, and snippets.

@Bamblehorse
Last active July 18, 2018 18:36
Show Gist options
  • Save Bamblehorse/79e48e1c8abb04a59e260cf1342090d3 to your computer and use it in GitHub Desktop.
Save Bamblehorse/79e48e1c8abb04a59e260cf1342090d3 to your computer and use it in GitHub Desktop.
function createFiles(path, name) {
const files = {
index: "index.jsx",
test: `${name}.test.js`,
sass: `${name}.sass`
};
if (name !== "components") {
const writeFile = writeToPath(path);
const toFileMissingBool = file => !fileExists(path)(file);
const checkAllMissing = (acc, cur) => acc && cur;
const noneExist = Object.values(files)
.map(toFileMissingBool)
.reduce(checkAllMissing);
if (noneExist) {
console.log(`Detected new component: ${name}, ${path}`);
Object.entries(files).forEach(([type, fileName]) => {
writeFile(fileName, templates[type](name));
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment