Comparing version 1.3.0 to 1.4.0
@@ -12,13 +12,16 @@ const fs = require('fs'); | ||
const writeFile = promisify(fs.writeFile); | ||
const exists = promisify(fs.exists); | ||
const { platform } = process; | ||
const BINARYEN_VERSION = 112; | ||
/** | ||
* Creates URL for wasm-opt binary | ||
* | ||
* @returns {Promise<string>} binary url | ||
* Creates a URL for the wasm-opt binary based on the current operating system and architecture. | ||
* @throws {Error} If the platform is not supported | ||
* @returns {Promise<string>} The binary URL | ||
*/ | ||
async function getUrl() { | ||
const { arch } = process; | ||
const baseURL = 'https://github.com/WebAssembly/binaryen/releases/download/version_105'; | ||
const baseURL = `https://github.com/WebAssembly/binaryen/releases/download/version_${BINARYEN_VERSION}`; | ||
@@ -28,3 +31,3 @@ switch (platform) { | ||
if (arch === 'x64') { | ||
return `${baseURL}/binaryen-version_105-x86_64-windows.tar.gz`; | ||
return `${baseURL}/binaryen-version_${BINARYEN_VERSION}-x86_64-windows.tar.gz`; | ||
} | ||
@@ -34,6 +37,6 @@ break; | ||
if (arch === 'arm64') { | ||
return `${baseURL}/binaryen-version_105-arm64-macos.tar.gz`; | ||
return `${baseURL}/binaryen-version_${BINARYEN_VERSION}-arm64-macos.tar.gz`; | ||
} | ||
if (arch === 'x64') { | ||
return `${baseURL}/binaryen-version_105-x86_64-macos.tar.gz`; | ||
return `${baseURL}/binaryen-version_${BINARYEN_VERSION}-x86_64-macos.tar.gz`; | ||
} | ||
@@ -43,3 +46,3 @@ break; | ||
if (arch === 'x64') { | ||
return `${baseURL}/binaryen-version_105-x86_64-linux.tar.gz`; | ||
return `${baseURL}/binaryen-version_${BINARYEN_VERSION}-x86_64-linux.tar.gz`; | ||
} | ||
@@ -53,5 +56,5 @@ break; | ||
/** | ||
* Returns wasm-opt or wasm-opt.exe string | ||
* | ||
* @returns {Promise<string>} name | ||
* Returns the filename of the wasm-opt executable depending on the platform. | ||
* @async | ||
* @returns {Promise<string>} The filename of the wasm-opt executable. | ||
*/ | ||
@@ -63,12 +66,17 @@ async function getExecutableFilename() { | ||
/** | ||
* Returns unpack folder name | ||
* | ||
* @returns {Promise<string>} unpack folder name | ||
* Get the name of the folder containing the unpacked Binaryen distribution archive. | ||
* @async | ||
* @function | ||
* @returns {Promise<string>} The name of the unpacked folder, in the format binaryen-version_X.Y.Z. | ||
*/ | ||
async function getUnpackedFolderName() { | ||
return 'binaryen-version_105'; | ||
return `binaryen-version_${BINARYEN_VERSION}`; | ||
} | ||
/** | ||
* Downloads binaries | ||
* Downloads and extracts Binaryen binaries, including wasm-opt and libbinaryen. | ||
* | ||
* @throws {Error} If an error occurs during the download or extraction process. | ||
* | ||
* @returns {Promise<void>} | ||
*/ | ||
@@ -116,4 +124,8 @@ async function main() { | ||
await mkdir(path.resolve(__dirname, `../${libFolder}`)); | ||
const outFolder = path.resolve(__dirname, `../${libFolder}`); | ||
if (!(await exists(outFolder))) { | ||
await mkdir(outFolder); | ||
} | ||
await copyFile(downloadedWasmOpt, outputWasmOpt); | ||
@@ -120,0 +132,0 @@ await copyFile(downloadedLibbinaryen, outputLibbinaryen); |
{ | ||
"name": "wasm-opt", | ||
"description": "Makes it possible to call wasm-opt in your project", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"main": "bin/wasm-opt.js", | ||
@@ -21,3 +21,3 @@ "bin": { | ||
"scripts": { | ||
"prepublishOnly": "npm run lint", | ||
"prepublishOnly": "rm -rf bin/wasm-opt && npm run lint", | ||
"postinstall": "node bin/index.js", | ||
@@ -28,8 +28,8 @@ "lint": "eslint ./bin --ext .js", | ||
"devDependencies": { | ||
"eslint": "^8.7.0" | ||
"eslint": "^8.36.0" | ||
}, | ||
"dependencies": { | ||
"node-fetch": "^2.6.7", | ||
"tar": "^6.1.11" | ||
"node-fetch": "^2.6.9", | ||
"tar": "^6.1.13" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6975
137
Updatednode-fetch@^2.6.9
Updatedtar@^6.1.13