Skip to content

Commit 2afceff

Browse files
committed
fix: npm install failure in dependencies due to unwanted post install script
1 parent de1f2d0 commit 2afceff

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- name: building package
1919
run: |
2020
npm run build
21+
npm run remove-postinstall
2122
- name: Publishing package to npm repository
2223
run: |
2324
npm publish --access public

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@phcode/fs",
33
"description": "Phoenix virtual file system over filer/ browser fs access/ tauri / phoenix web socket APIs",
4-
"version": "2.0.0",
4+
"version": "2.0.1",
55
"keywords": [
66
"phoenix",
77
"browser",
@@ -13,6 +13,8 @@
1313
"license": "GNU-AGPL3.0",
1414
"scripts": {
1515
"postinstall": "cd ./src-tauri/node-src/ && npm install && cd ../../",
16+
"prepublishOnly": "echo make sure to run `npm run remove-postinstall` before you run npm publish!!!",
17+
"remove-postinstall": "node src-build/remove-postinstall.js",
1618
"tauri": "tauri",
1719
"eslint": "eslint src test",
1820
"eslint:fix": "eslint src test --fix",

src-build/remove-postinstall.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const packageJsonPath = path.join(__dirname, '../package.json');
5+
const packageData = require(packageJsonPath);
6+
7+
// Remove the postinstall script
8+
if (packageData.scripts && packageData.scripts.postinstall) {
9+
delete packageData.scripts.postinstall;
10+
}
11+
12+
// Rewrite the package.json without the postinstall script
13+
fs.writeFileSync(packageJsonPath, JSON.stringify(packageData, null, 2) + '\n');

0 commit comments

Comments
 (0)