mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-17 00:13:17 +00:00
Check for correct wasm-bindgen-cli version (#92)
Two people pushing to the same branch is fraught. Three people pushing to the same branch is a circus. 😂 This should fix the build errors in #88!
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import chalk from "chalk";
|
||||
import cp from "node:child_process";
|
||||
import which from "which";
|
||||
|
||||
/**
|
||||
* @param {string} command
|
||||
@@ -25,3 +26,35 @@ export default function run(command, args, options) {
|
||||
.on("error", reject);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<string|null>}
|
||||
*/
|
||||
export async function wasmBindgenCliVersion() {
|
||||
const exePath = await which("wasm-bindgen", { nothrow: true });
|
||||
if (!exePath) return null;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
|
||||
const finish = code => {
|
||||
if (code) reject(new Error(stderr));
|
||||
else resolve(stdout);
|
||||
}
|
||||
|
||||
const proc = cp.spawn(exePath, ["--version"], {
|
||||
shell: true,
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
})
|
||||
.on("exit", finish)
|
||||
.on("close", finish)
|
||||
.on("error", reject);
|
||||
|
||||
proc.stdout.setEncoding("utf-8");
|
||||
proc.stdout.on("data", chunk => stdout += chunk);
|
||||
|
||||
proc.stderr.setEncoding("utf-8");
|
||||
proc.stderr.on("data", chunk => stderr += chunk);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user