Last active
July 18, 2018 18:36
-
-
Save Bamblehorse/79e48e1c8abb04a59e260cf1342090d3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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