Try to fix CI
All checks were successful
Check / build (pull_request) Successful in 9m24s

This commit is contained in:
Andras Schmelczer 2026-05-31 20:07:38 +01:00
parent c963db6cf2
commit c28a6b0685

View file

@ -3,7 +3,7 @@
// wasm2js (pure-JS) translation.
import { execFileSync } from 'node:child_process';
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { homedir } from 'node:os';
@ -66,26 +66,38 @@ function findWasmBindgen() {
return onPath;
}
// 2. In the wasm-pack cache: require the EXACT pinned version. wasm-pack stores each
// installed CLI under `wasm-bindgen-cargo-install-<version>/`.
const cached = [
resolve(
homedir(),
`Library/Caches/.wasm-pack/wasm-bindgen-cargo-install-${wanted}/wasm-bindgen`
),
resolve(
homedir(),
`.cache/.wasm-pack/wasm-bindgen-cargo-install-${wanted}/wasm-bindgen`
),
].find((p) => existsSync(p));
if (!cached) {
throw new Error(
`[build-rn] No wasm-bindgen ${wanted} found on PATH or in the wasm-pack cache. ` +
'Run `wasm-pack build --target web --features wasm` first (it caches the matching ' +
`wasm-bindgen), or \`cargo install wasm-bindgen-cli --version ${wanted}\`.`
);
const cacheRoots = [
resolve(homedir(), 'Library/Caches/.wasm-pack'),
resolve(homedir(), '.cache/.wasm-pack'),
];
for (const root of cacheRoots) {
if (!existsSync(root)) {
continue;
}
for (const entry of readdirSync(root)) {
const candidate = resolve(root, entry, 'wasm-bindgen');
if (!existsSync(candidate)) {
continue;
}
let version;
try {
version = execFileSync(candidate, ['--version'], { encoding: 'utf8' }).match(
/\d+\.\d+\.\d+/
)?.[0];
} catch {
continue; // not an invokable wasm-bindgen; ignore
}
if (version === wanted) {
return candidate;
}
}
}
return cached;
throw new Error(
`[build-rn] No wasm-bindgen ${wanted} found on PATH or in the wasm-pack cache. ` +
'Run `wasm-pack build --target web --features wasm` first (it caches the matching ' +
`wasm-bindgen), or \`cargo install wasm-bindgen-cli --version ${wanted}\`.`
);
}
if (!existsSync(releaseWasm)) {