From 1d85446ac4c64b10ed95a84b0760a8ec66237663 Mon Sep 17 00:00:00 2001 From: Tomson Kan Date: Wed, 11 Dec 2019 11:46:27 -0600 Subject: [PATCH 1/2] Final upload --- index.js | 50 +++++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 5 +++++ package.json | 1 + 3 files changed, 56 insertions(+) create mode 100644 index.js create mode 100644 package-lock.json create mode 100644 package.json diff --git a/index.js b/index.js new file mode 100644 index 0000000..848156c --- /dev/null +++ b/index.js @@ -0,0 +1,50 @@ + +'use strict'; + + +//checking if first process arg is "init" +if(process.argv[2] === "init") { +const fs = require('fs'); + + +const readline = require('readline'); + +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + + + +// console.log(process.argv) + +// const jsonObj = {} +// if(process.argv[2] === "init") { + // console.log(process.argv[2]) +rl.question("input number 1 ", (input1) => { + rl.question("input number 2 ", (input2) => { + rl.question("input number 3 ", (input3) => { + rl.question("input number 4 ", (input4) => { + rl.question("input number 5 ", (input5) => { + console.log(`${input1},${input2},${input3},${input4},${input5},`) + const obj = `{ + "input1" : ${input1}, + "input2" : ${input2}, + "input3" : ${input3}, + "input4" : ${input4}, + "input5" : ${input5}, + }` + const jsonString= JSON.stringify(obj); + fs.writeFile("package.json", jsonString, function (err) { + if (err) throw err; + console.log('Saved!'); + }) + + return rl.close() + }) + }) + }) + }) +}) +} + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..623c9e2 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "acapm", + "version": "1.0.0", + "lockfileVersion": 1 +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..919ae4d --- /dev/null +++ b/package.json @@ -0,0 +1 @@ +"{\n \"input1\" : 2,\n \"input2\" : 3,\n \"input3\" : 3,\n \"input4\" : 4,\n \"input5\" : 5,\n }" \ No newline at end of file From da49cef48402eab69b8f3b4cc7dc2e075e657839 Mon Sep 17 00:00:00 2001 From: Tomson Kan Date: Wed, 11 Dec 2019 11:47:28 -0600 Subject: [PATCH 2/2] revised --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 848156c..9716aae 100644 --- a/index.js +++ b/index.js @@ -37,7 +37,7 @@ rl.question("input number 1 ", (input1) => { const jsonString= JSON.stringify(obj); fs.writeFile("package.json", jsonString, function (err) { if (err) throw err; - console.log('Saved!'); + console.log('Already Saved!'); }) return rl.close()