Skip to content

Instantly share code, notes, and snippets.

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 elliotaplant/036337fe0cd12048dff40783b2d3ee5b to your computer and use it in GitHub Desktop.
Save elliotaplant/036337fe0cd12048dff40783b2d3ee5b to your computer and use it in GitHub Desktop.
// 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