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 | |
parent | ea14473db4ff4ffdf55684a8ae5092b89f1a6e7a (diff) | |
download | crupest-0477bd95a7b946f0431939b909697cac6ab251cb.tar.gz crupest-0477bd95a7b946f0431939b909697cac6ab251cb.tar.bz2 crupest-0477bd95a7b946f0431939b909697cac6ab251cb.zip |
service: remove dep dotenv.
-rw-r--r-- | deno/deno.json | 1 | ||||
-rw-r--r-- | deno/deno.lock | 5 | ||||
-rw-r--r-- | deno/tools/service.ts | 17 |
3 files changed, 14 insertions, 9 deletions
diff --git a/deno/deno.json b/deno/deno.json index 53cdf7a..d4beef0 100644 --- a/deno/deno.json +++ b/deno/deno.json @@ -11,7 +11,6 @@ "@std/io": "jsr:@std/io@^0.225.2", "@std/path": "jsr:@std/path@^1.1.0", "@std/testing": "jsr:@std/testing@^1.0.13", - "@std/dotenv": "jsr:@std/dotenv@^0.225.5", "@std/fs": "jsr:@std/fs@^1.0.18", "yargs": "npm:yargs@^18.0.0", "@types/yargs": "npm:@types/yargs@^17.0.33" diff --git a/deno/deno.lock b/deno/deno.lock index 871a9ae..9037ebe 100644 --- a/deno/deno.lock +++ b/deno/deno.lock @@ -10,7 +10,6 @@ "jsr:@std/collections@^1.1.1": "1.1.1", "jsr:@std/csv@^1.0.6": "1.0.6", "jsr:@std/data-structures@^1.0.8": "1.0.8", - "jsr:@std/dotenv@~0.225.5": "0.225.5", "jsr:@std/encoding@1": "1.0.10", "jsr:@std/encoding@^1.0.10": "1.0.10", "jsr:@std/expect@^1.0.16": "1.0.16", @@ -88,9 +87,6 @@ "@std/data-structures@1.0.8": { "integrity": "2fb7219247e044c8fcd51341788547575653c82ae2c759ff209e0263ba7d9b66" }, - "@std/dotenv@0.225.5": { - "integrity": "9ce6f9d0ec3311f74a32535aa1b8c62ed88b1ab91b7f0815797d77a6f60c922f" - }, "@std/encoding@1.0.10": { "integrity": "8783c6384a2d13abd5e9e87a7ae0520a30e9f56aeeaa3bdf910a3eaaf5c811a1" }, @@ -1300,7 +1296,6 @@ "dependencies": [ "jsr:@std/collections@^1.1.1", "jsr:@std/csv@^1.0.6", - "jsr:@std/dotenv@~0.225.5", "jsr:@std/encoding@^1.0.10", "jsr:@std/expect@^1.0.16", "jsr:@std/fs@^1.0.18", 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)) { |