Skip to content

Commit

Permalink
fix: rename wasm install dir no such dir
Browse files Browse the repository at this point in the history
  • Loading branch information
fz6m committed Nov 10, 2023
1 parent 9153491 commit c43ef02
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit c43ef02

Please sign in to comment.