fix(ci): resolve napi bin directly and allow const_for_fn on power stop

- build-native.ts: bunx @napi-rs/cli was picking up Mono's /usr/bin/cli
  on Ubuntu runners; resolve the napi bin from node_modules/.bin instead.
- power.rs: non-macOS build strips the cfg body, leaving stop() as a no-op
  that clippy wants const. Allow the lint since the macOS branch can't be const.
This commit is contained in:
can1357
2026-04-07 05:59:42 +02:00
parent c849bf6d30
commit fe762f6f26
2 changed files with 10 additions and 1 deletions
+1
View File
@@ -191,6 +191,7 @@ impl MacOSPowerAssertion {
/// Release the power assertion early.
#[napi]
#[allow(clippy::missing_const_for_fn, reason = "not const on macOS")]
pub fn stop(&mut self) -> napi::Result<()> {
#[cfg(target_os = "macos")]
if let Some(inner) = &mut self.inner {
+9 -1
View File
@@ -171,7 +171,15 @@ console.log(`Building pi-natives for ${targetPlatform}-${targetArch}${variantSuf
await fs.mkdir(nativeDir, { recursive: true });
await cleanupStaleTemps(nativeDir);
const buildResult = await $`bunx @napi-rs/cli ${napiArgs}`.nothrow();
// Resolve napi bin directly: `bunx @napi-rs/cli` can pick up the wrong bin on
// systems where `cli` exists on PATH (e.g. Mono's /usr/bin/cli on Ubuntu).
const napiBin = Bun.which("napi", {
PATH: `${path.join(import.meta.dir, "..", "node_modules", ".bin")}:${path.join(repoRoot, "node_modules", ".bin")}:${process.env.PATH ?? ""}`,
});
if (!napiBin) {
throw new Error("Could not locate @napi-rs/cli `napi` binary in node_modules/.bin");
}
const buildResult = await $`${napiBin} ${napiArgs}`.nothrow();
if (buildResult.exitCode !== 0) {
const stderr = buildResult.stderr?.toString("utf-8") ?? "";
throw new Error(`napi build failed${stderr ? `:\n${stderr}` : ""}`);