@broxus/wasm-pack
Version:
📦✨ your favorite rust -> wasm workflow tool!
51 lines (42 loc) • 1.13 kB
JavaScript
const { Binary } = require("binary-install");
const os = require("os");
const { join } = require("path");
const getPlatform = () => {
const type = os.type();
const arch = os.arch();
if (type === "Windows_NT" && arch === "x64") {
return "x86_64-pc-windows-msvc";
}
if (type === "Linux" && arch === "x64") {
return "x86_64-unknown-linux-musl";
}
if (type === "Darwin" && arch === "x64") {
return "x86_64-apple-darwin";
}
throw new Error(`Unsupported platform: ${type} ${arch}`);
};
const getBinary = () => {
const platform = getPlatform();
const version = require("./package.json").version;
const author = "broxus";
const name = "wasm-pack";
const url = `https://github.com/${author}/${name}/releases/download/v${version}/${name}-v${version}-${platform}.tar.gz`;
return new Binary(url, { name });
};
const run = () => {
const binary = getBinary();
binary.run();
};
const install = () => {
const binary = getBinary();
binary.install();
};
const uninstall = () => {
const binary = getBinary();
binary.uninstall();
};
module.exports = {
install,
run,
uninstall
};