Skip to content

Commit

Permalink
Remove the postinstall script during packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Jan 22, 2025
1 parent 49752ed commit 0c0c045
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bsc-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
"prepublishOnly": "npm run build",
"lint": "eslint \"src/**\"",
"build": "npm run compile && cp -r ../framework/src ./dist/lib/framework",
"postinstall": "ropm copy",
"test": "nyc mocha",
"test:nocover": "mocha",
"publish-coverage": "nyc report --reporter=text-lcov | coveralls",
"publish-npm": "npm run test && npm publish",
"publish-npm:beta": "npm run test && npm publish --tag=beta",
"local": "ts-node scripts/install-local.js",
"remote": "ts-node scripts/install-npm.js",
"cli": "ts-node src/cli.ts"
"cli": "ts-node src/cli.ts",
"prepack": "node scripts/pack.js --pre",
"postpack": "node scripts/pack.js --post",
"postinstall": "ropm copy"
},
"repository": {
"type": "git",
Expand Down
20 changes: 20 additions & 0 deletions bsc-plugin/scripts/pack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
var fsExtra = require('fs-extra');
var path = require('path');

var cachePath = path.join(__dirname, 'pack-cache.txt');
var packageJsonPath = path.join(__dirname, '../package.json');

var packageJson = fsExtra.readJsonSync(packageJsonPath);

//store the script and remove it from package.json
if (process.argv.includes('--pre')) {
fsExtra.outputFileSync(cachePath, packageJson.scripts.postinstall);
delete packageJson.scripts.postinstall;

//restore the script
} else if (process.argv.includes('--post')) {
packageJson.scripts.postinstall = fsExtra.readFileSync(cachePath, packageJson.scripts.postinstall).toString();
fsExtra.removeSync(cachePath);
}

fsExtra.outputJsonSync(packageJsonPath, packageJson, { spaces: 4 });

0 comments on commit 0c0c045

Please sign in to comment.