diff options
author | Mole Shang <[email protected]> | 2023-09-04 12:53:41 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2023-09-04 12:53:41 +0800 |
commit | 283b7a03b0254f272eae290e7fdce39a716cf4d2 (patch) | |
tree | 3cf00f7fc0a6859a0d29c37ab54b29de05c64f9e | |
parent | cccac1059dcb2cda84e9b7a2c1f6986b3aca8cd7 (diff) | |
download | seu_wlan_login-283b7a03b0254f272eae290e7fdce39a716cf4d2.tar.gz seu_wlan_login-283b7a03b0254f272eae290e7fdce39a716cf4d2.tar.bz2 seu_wlan_login-283b7a03b0254f272eae290e7fdce39a716cf4d2.zip |
load credentials.json from arg config path
-rw-r--r-- | index.js | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -12,11 +12,12 @@ const headers = { const flags = parse(Deno.args, { boolean: ["login", "logout"], - default: { login: true } + string: ["config"], + default: { login: true, config: "./credentials.json" } }); try { - const credentials = JSON.parse(await Deno.readTextFile("./credentials.json")); + const credentials = JSON.parse(await Deno.readTextFile(flags.config)); if (lodash.isEmpty(credentials.username) || lodash.isEmpty(credentials.password)) { throw "Invalid credentials! "; @@ -36,7 +37,7 @@ const headers = { if (err instanceof SyntaxError) { exitWithError("Parse json failed!"); } else if (err instanceof Deno.errors.NotFound) { - exitWithError("./credentials.json not found!") + exitWithError("credentials.json not found!") } else { console.error(`[ERROR]: ${err.toString()}`); |