Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -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();
};
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}