diff options
author | Mole Shang <[email protected]> | 2023-09-04 18:27:46 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2023-09-04 18:30:26 +0800 |
commit | e11bbc6c26d78cd5076268a4538f750f92b2596c (patch) | |
tree | 5c71b76c524f17b8e46910b6bad143fac42bf2f0 /index.js | |
parent | 283b7a03b0254f272eae290e7fdce39a716cf4d2 (diff) | |
download | seu_wlan_login-master.tar.gz seu_wlan_login-master.tar.bz2 seu_wlan_login-master.zip |
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -1,5 +1,6 @@ import lodash from "lodash"; import { parse } from "flags/mod.ts"; +import { dirname, fromFileUrl, SEP } from "path/mod.ts"; import { networkInterfaces } from "node:os"; const REFERER = "https://w.seu.edu.cn/"; @@ -7,13 +8,17 @@ const EPORTAL_API = "https://w.seu.edu.cn:802/eportal"; const headers = { "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0", }; +const PROG_PATH = Deno.args.includes("--is_compiled_binary") + ? Deno.execPath() + : fromFileUrl(Deno.mainModule); +const CONFIG_FILE = `${dirname(PROG_PATH)}${SEP}credentials.json`; (async () => { const flags = parse(Deno.args, { boolean: ["login", "logout"], string: ["config"], - default: { login: true, config: "./credentials.json" } + default: { login: true, config: CONFIG_FILE } }); try { @@ -37,7 +42,7 @@ const headers = { if (err instanceof SyntaxError) { exitWithError("Parse json failed!"); } else if (err instanceof Deno.errors.NotFound) { - exitWithError("credentials.json not found!") + exitWithError(`${CONFIG_FILE} not found!`) } else { console.error(`[ERROR]: ${err.toString()}`); |