diff --git a/index.js b/index.js new file mode 100644 index 0000000..4932bc4 --- /dev/null +++ b/index.js @@ -0,0 +1,41 @@ +//This allows users to enter input information. +const readline = require('readline'); +const fs = require('fs'); + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +//If the length of the input is 3 words, start listing questions. After +//each answer, list the next question. +if(process.argv.length === 2) { +console.log ('Answer the following:') + + rl.question('First Name: ', (r1) => { + rl.question('Last Name: ', (r2) => { + rl.question('Email: ', (r3) => { + rl.question('Phone Number: ', (r4) => { + rl.question('Address: ', (r5) => { + + //responses stored into variable "responses" + let responses = { + r1, r2, r3, r4, r5, + }; + +//after all questions are answered, end program and send responses as a string +//that is a JSON object to a new file called Package2.json) + rl.close(); + let data = JSON.stringify(responses); + fs.writeFileSync('package2.json', data); + console.log('Added data to: Package2.json'); + + }) + }) + }) + }) + }) +} else { + console.log('Error: Enter ("npm run init")'); + rl.close(); +}; \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ead5363 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "acapackmgr", + "version": "1.0.0", + "description": "* Create a node program * Check for the first process argument to be init * If the first argument is init continue processing else end the program * check if a file named package.json already exists, if it does exit the program * Use readline to ask for 5 inputs * Create a string that is a json object * The key values should be the inputs you get from the user * Save this json to a file called package.json", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1", + "init": "node index.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/DMuttz/acapm.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/DMuttz/acapm/issues" + }, + "homepage": "https://github.com/DMuttz/acapm#readme" +}