diff --git a/build b/build index eb6717d49..6fb680ae9 100755 --- a/build +++ b/build @@ -75,8 +75,6 @@ default: break; } -execSync(`node ./build-tools/update` + full, options); - if (full) { try { execSync(`node ./build-tools/build-commands`, options); @@ -84,3 +82,5 @@ if (full) { console.error(e); } } + +execSync(`node ./build-tools/update` + full, options); diff --git a/build-tools/build-indexes b/build-tools/build-indexes index f83a9113a..e40dd3d4d 100755 --- a/build-tools/build-indexes +++ b/build-tools/build-indexes @@ -6,6 +6,8 @@ const child_process = require('node:child_process'); process.chdir(__dirname + '/..'); +fs.mkdirSync('play.pokemonshowdown.com/data', { recursive: true }); + const noUpdate = process.argv.includes('--no-update'); if (!fs.existsSync('caches/pokemon-showdown')) { if (noUpdate) { diff --git a/build-tools/compiler.mjs b/build-tools/compiler.mjs index 42a51b6bf..2c3eb0f33 100644 --- a/build-tools/compiler.mjs +++ b/build-tools/compiler.mjs @@ -182,7 +182,7 @@ function compileToDir(srcDir, destDir, opts = {}) { return total; } -function compileToFile(srcFile, destFile, opts) { +async function compileToFile(srcFile, destFile, opts) { const incremental = opts.incremental; delete opts.incremental; @@ -205,12 +205,11 @@ function compileToFile(srcFile, destFile, opts) { if (VERBOSE) console.log(src + " ->"); } - combineResults(results, { + const combined = await combineResults(results, { file: path.basename(destFile), sourceRoot: opts.sourceRoot, - }, opts).then(combined => { - outputFileSync(destFile, combined, opts); - }); + }, opts); + outputFileSync(destFile, combined, opts); if (VERBOSE) console.log("-> " + destFile); if (incremental) opts.incremental = true; // incredibly dumb hack to preserve the option diff --git a/build-tools/update b/build-tools/update index 06686a967..60b698010 100755 --- a/build-tools/update +++ b/build-tools/update @@ -6,14 +6,12 @@ * It also updates news and the learnsets-g6.js file. */ -"use strict"; +import fs from 'node:fs'; +import crypto from 'node:crypto'; +import child_process from 'node:child_process'; +import * as compiler from './compiler.mjs'; -const fs = require('node:fs'); -const crypto = require('node:crypto'); -const child_process = require('node:child_process'); -const compiler = require('./compiler.mjs'); - -process.chdir(__dirname + '/..'); +process.chdir(import.meta.dirname + '/..'); const AUTOCONFIG_START = '/*** Begin automatically generated configuration ***/'; const AUTOCONFIG_END = '/*** End automatically generated configuration ***/'; @@ -38,7 +36,7 @@ function readOptionalFile(filename) { process.stdout.write("Updating version... "); -let version = require('../package.json').version; +let version = JSON.parse(fs.readFileSync('package.json', UTF8)).version; try { let commit = child_process.execSync('git rev-parse HEAD', { stdio: ['ignore', 'pipe', 'ignore'], @@ -130,7 +128,7 @@ compiledFiles += compiler.compileToDir(`teams.pokemonshowdown.com/src`, `teams.p try { fs.statSync('play.pokemonshowdown.com/data/text/en.js'); // English text exists, we can compile battledata - compiledFiles += compiler.compileToFile( + compiledFiles += await compiler.compileToFile( [ 'play.pokemonshowdown.com/src/battle-dex.ts', 'play.pokemonshowdown.com/src/battle-teams.ts', @@ -147,7 +145,7 @@ try { } catch {} if (!compileOpts.ignore) { - compiledFiles += compiler.compileToFile( + compiledFiles += await compiler.compileToFile( ['play.pokemonshowdown.com/src/battle-animations.ts', 'play.pokemonshowdown.com/src/battle-animations-moves.ts'], 'play.pokemonshowdown.com/data/graphics.js', compileOpts