diff options
author | Yuqian Yang <crupest@outlook.com> | 2025-06-29 15:50:31 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@outlook.com> | 2025-06-29 15:50:31 +0800 |
commit | 0477bd95a7b946f0431939b909697cac6ab251cb (patch) | |
tree | 98c8058d282a7873000f1ba84a973a28976a0c7f /deno/tools/service.ts | |
parent | ea14473db4ff4ffdf55684a8ae5092b89f1a6e7a (diff) | |
download | crupest-0477bd95a7b946f0431939b909697cac6ab251cb.tar.gz crupest-0477bd95a7b946f0431939b909697cac6ab251cb.tar.bz2 crupest-0477bd95a7b946f0431939b909697cac6ab251cb.zip |
service: remove dep dotenv.
Diffstat (limited to 'deno/tools/service.ts')
-rw-r--r-- | deno/tools/service.ts | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/deno/tools/service.ts b/deno/tools/service.ts index 1172473..bd4d22c 100644 --- a/deno/tools/service.ts +++ b/deno/tools/service.ts @@ -1,6 +1,5 @@ import { dirname, join, relative } from "@std/path"; import { copySync, existsSync, walkSync } from "@std/fs"; -import { parse } from "@std/dotenv"; import { distinct } from "@std/collections"; // @ts-types="npm:@types/mustache" import Mustache from "mustache"; @@ -36,8 +35,20 @@ function loadTemplatedConfigFiles( for (const file of files) { console.log(` from file ${file}`); const text = Deno.readTextFileSync(file); - for (const [key, valueText] of Object.entries(parse(text))) { - // TODO: dotenv silently override old values, so everything will be new for now. + let lineNumber = 0; + for (const rawLine of text.split("\n")) { + lineNumber++; + const line = rawLine.trim(); + if (line.length === 0) continue; + if (line.startsWith("#")) continue; + const equalSymbolIndex = line.indexOf("="); + if (equalSymbolIndex === -1) { + throw new Error(`Line ${lineNumber} of ${file} is invalid.`); + } + const [key, valueText] = [ + line.slice(0, equalSymbolIndex).trim(), + line.slice(equalSymbolIndex + 1).trim(), + ]; console.log(` (${key in config ? "override" : "new"}) ${key}`); getVariableKeysOfTemplate(valueText).forEach((name) => { if (!(name in config)) { |