Don't rebuild if installed by NPM package

This commit is contained in:
Guangcong Luo 2023-04-14 11:41:54 +09:00
parent 72e104e722
commit 1cea3f39cb
No known key found for this signature in database
2 changed files with 9 additions and 6 deletions

13
build
View File

@ -30,11 +30,6 @@ try {
console.log('Installing dependencies...');
shell('npm install');
}
// for some reason, esbuild won't be requirable until a tick has passed
// see https://stackoverflow.com/questions/53270058/node-cant-find-certain-modules-after-synchronous-install
setImmediate(() => {
require('./tools/build-utils').transpile(force, decl);
});
// Make sure config.js exists. If not, copy it over synchronously from
// config-example.js, since it's needed before we can start the server
@ -49,3 +44,11 @@ try {
fs.readFileSync('config/config-example.js')
);
}
// for some reason, esbuild won't be requirable until a tick has passed
// see https://stackoverflow.com/questions/53270058/node-cant-find-certain-modules-after-synchronous-install
setImmediate(() => {
// npm package, don't rebuild
if (process.argv[2] === 'postinstall' && fs.existsSync('dist')) return;
require('./tools/build-utils').transpile(force, decl);
});

View File

@ -40,7 +40,7 @@
"test": "mocha",
"posttest": "npm run tsc",
"full-test": "npm run lint && npm run tsc && mocha --timeout 8000 --forbid-only -g \".*\"",
"postinstall": "npm run build"
"postinstall": "npm run build postinstall"
},
"bin": "./pokemon-showdown",
"homepage": "http://pokemonshowdown.com",