Created
March 7, 2018 04:01
-
-
Save Bastiani/f938bae5f99010a881b825c243246b04 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
const fs = require('fs'); | |
const readline = require('readline'); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
terminal: false | |
}); | |
const paths = [ | |
{ path: 'graphql/connection/', tag: 'Connection' }, | |
{ path: 'graphql/loader/', tag: 'Loader' }, | |
{ path: 'graphql/mutation/', tag: 'Mutation' }, | |
{ path: 'graphql/type/', tag: 'Type' } | |
]; | |
function CreateFiles(projectDir, fileName) { | |
paths.map(({ path, tag }) => { | |
fs.writeFile(`${projectDir}${path}${fileName}${tag}.js`, null, function (err) { | |
if (err) { | |
return console.log(err); | |
} | |
console.log(`${path}${fileName} file was saved!`); | |
}); | |
}); | |
} | |
let cont = 0; | |
let values = []; | |
rl.setPrompt('Project Folder: '); | |
rl.prompt(); | |
rl.on('line', function (line) { | |
cont += 1; | |
values = [...values, line]; | |
if (cont === 2) { | |
CreateFiles(values[0], values[1]); | |
rl.close(); | |
process.stdin.destroy(); | |
} else { | |
rl.setPrompt('File Name: '); | |
rl.prompt(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
great! 👍