Last active
May 10, 2018 23:15
-
-
Save elliotaplant/036337fe0cd12048dff40783b2d3ee5b to your computer and use it in GitHub Desktop.
Sets up folder structure for https://start.jcolemorrison.com/react-and-redux-sagas-authentication-app-tutorial/
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
// Sets up files for https://start.jcolemorrison.com/react-and-redux-sagas-authentication-app-tutorial/ | |
const fs = require('fs'); | |
const root = { | |
src: { | |
login: [ | |
'sagas.js', 'reducer.js', 'actions.js', 'constants.js', 'index.jsx' | |
], | |
signup: [ | |
'sagas.js', 'reducer.js', 'actions.js', 'constants.js', 'index.jsx' | |
], | |
widgets: [ | |
'sagas.js', 'reducer.js', 'actions.js', 'constants.js', 'index.jsx' | |
], | |
client: [ | |
'reducer.js', 'actions.js', 'constants.js' | |
], | |
notifications: [ | |
'Messages.js', 'Errors.js' | |
], | |
lib: ['api-errors.js', 'check-auth.js'] | |
}, | |
'index-reducer.js': null, | |
'index-sagas.js': null | |
} | |
// Iterates through root object creating appropriate folders and files. | |
// Assumes you already have a <root>/src directory | |
Object.keys(root).forEach(rootKey => { | |
if (rootKey.endsWith('.js') || rootKey.endsWith('.jsx')) { | |
fs.writeFileSync(`./${rootKey}`, `// ${rootKey}`); | |
} else if (rootKey === 'src') { | |
Object.keys(root.src).forEach(srcKey => { | |
fs.mkdirSync(`./src/${srcKey}`); | |
root.src[srcKey].forEach(filename => { | |
fs.writeFileSync(`./src/${srcKey}/${filename}`, `// ${filename}`); | |
}) | |
}) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment