Skip to content

Commit

Permalink
fix: execute postinstall script iff in development mode (#1132)
Browse files Browse the repository at this point in the history
Fixes: #1131

---------

Co-authored-by: Ayushman Chhabra <[email protected]>
  • Loading branch information
TheJaredWilcurt and ayushmanchhabra authored Jun 22, 2024
1 parent b4cb5fa commit 3c68216
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"url": "https://github.com/nwutils/nw-builder.git"
},
"scripts": {
"postinstall": "base-volta-off-of-nwjs",
"postinstall": "node ./src/postinstall.js",
"lint": "eslint ./src/**/*.js ./test/**/*.js",
"lint:fix": "eslint --fix ./src/**/*.js ./test/**/*.js",
"markdown:fix": "markdownlint --fix ./README.md",
Expand Down Expand Up @@ -75,10 +75,7 @@
"yargs": "^17.7.2",
"yauzl-promise": "^4.0.0"
},
"packageManager": "[email protected]",
"engines": {
"node": ">=14"
},
"packageManager": "[email protected]",
"volta": {
"node": "22.0.0"
}
Expand Down
13 changes: 13 additions & 0 deletions src/postinstall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import child_process from 'node:child_process';
import fs from 'node:fs';
import path from 'node:path';
import url from 'node:url';

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

const baseVoltaPath = path.resolve(path.join(__dirname, '..', 'node_modules', 'base-volta-off-of-nwjs', 'index.js'));

/* Execute the script in development mode only since it is used during testing */
if (fs.existsSync(baseVoltaPath)) {
child_process.execSync('node ' + baseVoltaPath);
}

0 comments on commit 3c68216

Please sign in to comment.