mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-26 02:39:38 -05:00
Hotpatching and running `./pokemon-showdown` now automatically run `./build`. There should now mostly not be any reason you'd want to manually run `./build`, except if you're invoking tests directly. In addition, a lot of redundant code has been removed. I'm not 100% sure this works on Windows, but I'm sure I'll get reports if anything breaks.
38 lines
1.0 KiB
JavaScript
Executable File
38 lines
1.0 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
try {
|
|
RegExp("\\p{Emoji}", "u");
|
|
} catch (e) {
|
|
console.log("We require Node.js version 10 or later; you're using " + process.version);
|
|
process.exit(1);
|
|
}
|
|
|
|
var child_process = require('child_process');
|
|
var fs = require('fs');
|
|
var path = require('path');
|
|
|
|
function shell(cmd) { child_process.execSync(cmd, {stdio: 'inherit', cwd: __dirname}); }
|
|
|
|
try {
|
|
require.resolve('sucrase');
|
|
} catch (e) {
|
|
console.log('Installing dependencies...');
|
|
shell('npm install');
|
|
}
|
|
|
|
shell('npx sucrase -q ./sim -d ./.sim-dist --transforms typescript,imports');
|
|
|
|
// 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
|
|
try {
|
|
require.resolve('./config/config');
|
|
} catch (err) {
|
|
if (err.code !== 'MODULE_NOT_FOUND') throw err; // should never happen
|
|
|
|
console.log('config.js does not exist. Creating one with default settings...');
|
|
fs.writeFileSync(
|
|
path.resolve(__dirname, 'config/config.js'),
|
|
fs.readFileSync(path.resolve(__dirname, 'config/config-example.js'))
|
|
);
|
|
}
|