Skip to content

Commit

Permalink
Don't rebuild if installed by NPM package
Browse files Browse the repository at this point in the history
  • Loading branch information
Zarel committed Apr 14, 2023
1 parent 72e104e commit 1cea3f3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 1cea3f3

Please sign in to comment.