diff options
author | Lenvin Gonsalves <41874033+98lenvi@users.noreply.github.com> | 2022-09-16 01:03:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-16 01:03:40 +0300 |
commit | 85b46e1cab0f91eb87ff30f14bee0b456a63c83b (patch) | |
tree | b21a49da892946e306779831bd77178c947e2c6b /tools | |
parent | 1f19f0c389f14fdab6ce68ec2caccf55c65a9aa5 (diff) |
tools: add timezone update workflow
Fixes: https://github.com/nodejs/node/issues/43134
PR-URL: https://github.com/nodejs/node/pull/43988
Reviewed-By: Steven R Loomis <srloomis@us.ibm.com>
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/update-timezone.mjs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tools/update-timezone.mjs b/tools/update-timezone.mjs new file mode 100755 index 00000000000..33da42f4e98 --- /dev/null +++ b/tools/update-timezone.mjs @@ -0,0 +1,39 @@ +#!/usr/bin/env node +// Usage: tools/update-timezone.mjs +import { execSync, spawnSync } from 'node:child_process'; +import { renameSync, readdirSync, rmSync } from 'node:fs'; +import { exit } from 'node:process'; + +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 currentVersion = process.versions.tz; +const latestVersion = availableVersions.sort().at(-1); + +if (latestVersion === currentVersion) { + console.log(`Terminating early, tz version is latest @ ${currentVersion}`); + exit(); +} + +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}`); + spawnSync( + '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 }); |