From c43ef02a9c3ad2d5f210fdb22459bf592e550831 Mon Sep 17 00:00:00 2001 From: fz6m <59400654+fz6m@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:50:24 +0800 Subject: [PATCH] fix: rename wasm install dir no such dir --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- postinstall.js | 8 ++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 05b381d..88d4a11 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "@types/node": "^18.18.5", "@vitest/ui": "^0.34.6", "@xn-sakina/mental": "^4.0.2", - "@xn-sakina/vary": "^1.3.3", + "@xn-sakina/vary": "^1.3.4", "es-module-lexer": "^1.3.1", "esbuild": "^0.19.4", "husky": "^8.0.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6fd244a..3a3d8da 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,8 +27,8 @@ importers: specifier: ^4.0.2 version: registry.npmjs.org/@xn-sakina/mental@4.0.2 '@xn-sakina/vary': - specifier: ^1.3.3 - version: registry.npmjs.org/@xn-sakina/vary@1.3.3 + specifier: ^1.3.4 + version: registry.npmjs.org/@xn-sakina/vary@1.3.4 es-module-lexer: specifier: ^1.3.1 version: registry.npmjs.org/es-module-lexer@1.3.1 @@ -1476,10 +1476,10 @@ packages: version: 4.0.2 dev: true - registry.npmjs.org/@xn-sakina/vary@1.3.3: - resolution: {integrity: sha512-lhHMsnLWdBI+hWWfzh55rvC6JHl8yEZP+zqEiU7zXgUO0CgEoUdn066cS6nA3O5p2L3FfpwtO9QLIvqVj4PQ8A==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@xn-sakina/vary/-/vary-1.3.3.tgz} + registry.npmjs.org/@xn-sakina/vary@1.3.4: + resolution: {integrity: sha512-rD46oF29hsb0zqyAQtY/HW1K/qbrr0R7rjrQ0Pfo7PGwIgPGJRdjpN+RCi38jAiI12IDvXK1yak+eBqXRCmCKQ==, registry: https://registry.npmjs.com/, tarball: https://registry.npmjs.org/@xn-sakina/vary/-/vary-1.3.4.tgz} name: '@xn-sakina/vary' - version: 1.3.3 + version: 1.3.4 hasBin: true dependencies: '@manypkg/get-packages': registry.npmjs.org/@manypkg/get-packages@2.2.0 diff --git a/postinstall.js b/postinstall.js index 5e8d138..8cd33a3 100644 --- a/postinstall.js +++ b/postinstall.js @@ -106,7 +106,7 @@ var getWasmName = function () { }; var wasmName = getWasmName(); var validateBinary = function () { return __awaiter(void 0, void 0, void 0, function () { - var name_1, binding, triple, wasmBinding, env, _a, version, repository, coreDir, installDir, installedBinPath, reportText; + var name_1, binding, triple, wasmBinding, env, _a, version, repository, coreDir, installDir, installedBinPath, targetPath, reportText; var _b, _c; return __generator(this, function (_d) { try { @@ -154,8 +154,12 @@ var validateBinary = function () { return __awaiter(void 0, void 0, void 0, func fs.writeFileSync(path.join(installDir, 'package.json'), '{}'); child_process.execSync("npm install --no-save --loglevel=error --prefer-offline --no-audit --progress=false ".concat(wasmName, "@").concat(version), { cwd: installDir, stdio: 'pipe', env: env }); installedBinPath = path.join(installDir, 'node_modules', wasmName); + targetPath = path.resolve(process.env.INIT_CWD, 'node_modules', wasmName); + if (!fs.existsSync(targetPath)) { + fs.mkdirSync(targetPath, { recursive: true }); + } // INIT_CWD is injected via npm. If it doesn't exists, can't proceed. - fs.renameSync(installedBinPath, path.resolve(process.env.INIT_CWD, 'node_modules', wasmName)); + fs.renameSync(installedBinPath, targetPath); } catch (error) { console.error(error);