0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-24 03:07:54 +01:00
nodejs/tools/update-timezone.mjs
Darshan Sen b5add9757d tools: remove faulty early termination logic from update-timezone.mjs
We do not build Node.js in the workflow so
f4815fcd76/tools/update-timezone.mjs (L18)
is actually the version of `tzdata` in the Node.js in the runner instead
of what's in `main`.

The script is pretty fast even when the versions differ and there is an
update, so this optimization doesn't seem to be worth having given the
problem.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/44870
Fixes: https://github.com/nodejs/node/issues/44865
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-10-10 15:23:50 +00:00

27 lines
945 B
JavaScript
Executable File

#!/usr/bin/env node
// Usage: tools/update-timezone.mjs
import { execSync } from 'node:child_process';
import { renameSync, readdirSync, rmSync } from 'node:fs';
const fileNames = [
'zoneinfo64.res',
'windowsZones.res',
'timezoneTypes.res',
'metaZones.res',
];
const availableVersions = readdirSync('icu-data/tzdata/icunew', { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);
const latestVersion = availableVersions.sort().at(-1);
execSync('bzip2 -d deps/icu-small/source/data/in/icudt*.dat.bz2');
fileNames.forEach((file) => {
renameSync(`icu-data/tzdata/icunew/${latestVersion}/44/le/${file}`, `deps/icu-small/source/data/in/${file}`);
execSync(`icupkg -a ${file} icudt*.dat`, { cwd: 'deps/icu-small/source/data/in/' });
rmSync(`deps/icu-small/source/data/in/${file}`);
});
execSync('bzip2 -z deps/icu-small/source/data/in/icudt*.dat');
rmSync('icu-data', { recursive: true });