From 0210498f9ec703a322f73cdcc868ddf6294aa611 Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Mon, 3 Oct 2022 10:46:48 +0530 Subject: [PATCH 1/2] tools: fix timezone update tool The spawnSync call was previously silently failing with this error: ```sh icupkg: unable to open input file "icudt*.dat" ``` because spawnSync doesn't support globbing. This change replaces the spawnSync call with execSync because that supports globbing. I have tested this workflow with some minor modifications in my fork and I can confirm that it works as expected now. The bot opened this PR - https://github.com/RaisinTen/node/pull/2 which updates deps/icu-small/source/data/in/icudt71l.dat.bz2. Fixes: https://github.com/nodejs/node/issues/44865 Signed-off-by: Darshan Sen --- tools/update-timezone.mjs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tools/update-timezone.mjs b/tools/update-timezone.mjs index 33da42f4e983fa..bf3498b8abf230 100755 --- a/tools/update-timezone.mjs +++ b/tools/update-timezone.mjs @@ -1,6 +1,6 @@ #!/usr/bin/env node // Usage: tools/update-timezone.mjs -import { execSync, spawnSync } from 'node:child_process'; +import { execSync } from 'node:child_process'; import { renameSync, readdirSync, rmSync } from 'node:fs'; import { exit } from 'node:process'; @@ -26,13 +26,7 @@ if (latestVersion === currentVersion) { 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/' } - ); + 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'); From 33d4ff6c52fb70dbc2838a498ad07c2a2beef1a9 Mon Sep 17 00:00:00 2001 From: Darshan Sen Date: Mon, 3 Oct 2022 15:48:06 +0530 Subject: [PATCH 2/2] tools: remove faulty early termination logic from update-timezone.mjs We do not build Node.js in the workflow so https://github.com/nodejs/node/blob/f4815fcd7691364d8139b44c1295dbc46f6ee4a8/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 --- tools/update-timezone.mjs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tools/update-timezone.mjs b/tools/update-timezone.mjs index bf3498b8abf230..bf3a706bdb0684 100755 --- a/tools/update-timezone.mjs +++ b/tools/update-timezone.mjs @@ -2,7 +2,6 @@ // Usage: tools/update-timezone.mjs import { execSync } from 'node:child_process'; import { renameSync, readdirSync, rmSync } from 'node:fs'; -import { exit } from 'node:process'; const fileNames = [ 'zoneinfo64.res', @@ -15,14 +14,8 @@ const availableVersions = readdirSync('icu-data/tzdata/icunew', { withFileTypes: .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}`);