Merge branch 'main' into update-version

This commit is contained in:
rewin
2024-03-27 22:56:50 +03:00
90 changed files with 7820 additions and 977 deletions
+6 -5
View File
@@ -2,11 +2,12 @@ import fs from "node:fs";
import url from "node:url";
import path from "node:path";
import { rimraf } from "rimraf";
import which from "which";
import copyAssets from "./copy-assets.mjs";
import handleError from "./handle-error.mjs";
import run from "./run.mjs";
import run, { wasmBindgenCliVersion } from "./run.mjs";
const WASM_BINDGEN_CLI_VERSION = "0.2.92";
async function main() {
try {
@@ -39,11 +40,11 @@ async function main() {
stdio,
});
const wasmBindgenInstalled = Boolean(await which("wasm-bindgen", { nothrow: true }));
if (!wasmBindgenInstalled) {
const wbVersion = await wasmBindgenCliVersion();
if (!wbVersion || !wbVersion.includes(WASM_BINDGEN_CLI_VERSION)) {
await run("cargo", [
"install", "-f", "wasm-bindgen-cli",
"--version", "0.2.88",
"--version", WASM_BINDGEN_CLI_VERSION,
], {
shell: true,
cwd: workspaceRoot,
+33
View File
@@ -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);
});
}