From 64f9836fb2a6b67e887061958dbd07389e338093 Mon Sep 17 00:00:00 2001 From: Amos Jones Date: Sat, 31 Aug 2019 10:03:00 -0400 Subject: [PATCH 1/2] Error: Cannot find module redis SourceDir: /home/ubuntu --- hostcontrol.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 hostcontrol.js diff --git a/hostcontrol.js b/hostcontrol.js new file mode 100755 index 0000000..d906964 --- /dev/null +++ b/hostcontrol.js @@ -0,0 +1,20 @@ +#! /usr/bin/env node + +//you must add the absolute path to hosts.js on line 4, or this file will NOT work +const hosts = require("./models/hosts.js") + + +if (process.argv[2] == "--list"){ + console.log(hosts.listAll()) +} +/* + if process.argv[2] == "--info" + + if process.agrv[2] == "--add" + + if process.argv[2] == "--remove" + + else{ + console.log("help text") + } +*/ \ No newline at end of file From 9d604f3b9c0f294211beda5b7616104ec3f6ad8d Mon Sep 17 00:00:00 2001 From: William Mantly Date: Sat, 31 Aug 2019 10:14:19 -0400 Subject: [PATCH 2/2] using async --- hostcontrol.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hostcontrol.js b/hostcontrol.js index d906964..8389943 100755 --- a/hostcontrol.js +++ b/hostcontrol.js @@ -3,10 +3,15 @@ //you must add the absolute path to hosts.js on line 4, or this file will NOT work const hosts = require("./models/hosts.js") +const command = process.argv[2]; -if (process.argv[2] == "--list"){ - console.log(hosts.listAll()) -} +(async function(command){ + if (command == "--list"){ + console.log(await hosts.listAll()) + process.exit(0) + } + +})(command) /* if process.argv[2] == "--info"