summaryrefslogtreecommitdiffhomepage
path: root/nix/scripts/patch-wasm.ts
diff options
context:
space:
mode:
authorCaleb Norton <[email protected]>2026-01-18 11:14:13 -0600
committerGitHub <[email protected]>2026-01-18 11:14:13 -0600
commitdac099a4892689d11abedb0fcc1098b50e0958c8 (patch)
treeb47a7a4bae294e0d4222fac21605a380d54b3341 /nix/scripts/patch-wasm.ts
parent5009f10406c15c4b69c04fa626756ee7bf81b300 (diff)
downloadopencode-dac099a4892689d11abedb0fcc1098b50e0958c8.tar.gz
opencode-dac099a4892689d11abedb0fcc1098b50e0958c8.zip
feat(nix): overhaul nix flake and packages (#9032)
Diffstat (limited to 'nix/scripts/patch-wasm.ts')
-rw-r--r--nix/scripts/patch-wasm.ts43
1 files changed, 0 insertions, 43 deletions
diff --git a/nix/scripts/patch-wasm.ts b/nix/scripts/patch-wasm.ts
deleted file mode 100644
index 88a06c2bd..000000000
--- a/nix/scripts/patch-wasm.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env bun
-
-import fs from "fs"
-import path from "path"
-
-/**
- * Rewrite tree-sitter wasm references inside a JS file to absolute paths.
- * argv: [node, script, file, mainWasm, ...wasmPaths]
- */
-const [, , file, mainWasm, ...wasmPaths] = process.argv
-
-if (!file || !mainWasm) {
- console.error("usage: patch-wasm <file> <mainWasm> [wasmPaths...]")
- process.exit(1)
-}
-
-const content = fs.readFileSync(file, "utf8")
-const byName = new Map<string, string>()
-
-for (const wasm of wasmPaths) {
- const name = path.basename(wasm)
- byName.set(name, wasm)
-}
-
-let next = content
-
-for (const [name, wasmPath] of byName) {
- next = next.replaceAll(name, wasmPath)
-}
-
-next = next.replaceAll("tree-sitter.wasm", mainWasm).replaceAll("web-tree-sitter/tree-sitter.wasm", mainWasm)
-
-// Collapse any relative prefixes before absolute store paths (e.g., "../../../..//nix/store/...")
-const nixStorePrefix = process.env.NIX_STORE || "/nix/store"
-next = next.replace(/(\.\/)+/g, "./")
-next = next.replace(
- new RegExp(`(\\.\\.\\/)+\\/{1,2}(${nixStorePrefix.replace(/^\//, "").replace(/\//g, "\\/")}[^"']+)`, "g"),
- "/$2",
-)
-next = next.replace(new RegExp(`(["'])\\/{2,}(\\/${nixStorePrefix.replace(/\//g, "\\/")}[^"']+)(["'])`, "g"), "$1$2$3")
-next = next.replace(new RegExp(`(["'])\\/\\/(${nixStorePrefix.replace(/\//g, "\\/")}[^"']+)(["'])`, "g"), "$1$2$3")
-
-if (next !== content) fs.writeFileSync(file, next)