commit 22ea3b8a62090ddd523322ebf8ae13ef1ea8ec50
parent c21659c4fe913d98e83042c4a1babbbb44f50743
Author: triesap <triesap@radroots.dev>
Date: Thu, 20 Nov 2025 16:44:50 +0000
themes: refactor build script to get the package root from argv
Diffstat:
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/themes/src/bin/build.ts b/themes/src/bin/build.ts
@@ -2,7 +2,6 @@
import fs from "node:fs";
import path from "node:path";
-import { fileURLToPath } from "node:url";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { z } from "zod";
@@ -18,8 +17,17 @@ const args_schema = z.object({
type BuildArgs = z.infer<typeof args_schema>;
-const script_dir = path.dirname(fileURLToPath(import.meta.url));
-const package_root = path.resolve(script_dir, "..", "..");
+const resolve_script_dir = (): string => {
+ const script_path = process.argv[1];
+
+ if (script_path === undefined) {
+ throw new Error("script path unavailable");
+ }
+
+ return path.dirname(path.resolve(script_path));
+};
+
+const package_root = path.resolve(resolve_script_dir(), "..", "..");
const css_output_dir = path.resolve(package_root, "css");
const styles_output_path = path.resolve(css_output_dir, "styles.css");
const layout_output_path = path.resolve(css_output_dir, "layout.css");