pokemon-showdown-client/build
Guangcong Luo 1a3e03bff6 Bump Node version requirement to 10
Apparently assert.strict doesn't exist on Node 8.
2018-10-16 03:52:16 -05:00

74 lines
1.8 KiB
JavaScript
Executable File

#!/usr/bin/env node
if (!require('assert').strict) {
console.error("We require Node.js version 10 or later; you're using " + process.version);
process.exit(1);
}
var execSync = require('child_process').execSync;
var fs = require('fs');
var path = require('path');
try {
require.resolve('@babel/core');
} catch (e) {
console.log('Installing dependencies...');
execSync('npm install', {stdio: 'inherit'});
}
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'))
);
}
var options = {cwd: __dirname, stdio: 'inherit'};
var full = '';
switch (process.argv[2] || '') {
case 'full':
execSync(`node ./build-tools/build-indexes`, options);
execSync(`node ./build-tools/build-learnsets`, options);
execSync(`node ./build-tools/build-minidex`, options);
full = ' full';
break;
case 'indexes':
execSync(`node ./build-tools/build-indexes`, options);
break;
case 'learnsets':
execSync(`node ./build-tools/build-learnsets`, options);
break;
case 'minidex':
case 'sprites':
execSync(`node ./build-tools/build-minidex`, options);
break;
case 'replays':
execSync(`node ../replay.pokemonshowdown.com/build`, options);
process.exit();
break;
case 'test-only':
break;
case '':
break;
default:
console.log(`Unrecognized command ${process.argv[2]}`);
process.exit();
break;
}
execSync(`node ./build-tools/update` + full, options);
if (process.argv[2] === 'full') {
try {
fs.statSync('../replay.pokemonshowdown.com/build');
execSync(`node ../replay.pokemonshowdown.com/build`, options);
} catch (e) {}
}