diff options
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()}`); |