Skip to content

Commit

Permalink
tools: fix timezone update tool
Browse files Browse the repository at this point in the history
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 -
RaisinTen/node#2 which updates
deps/icu-small/source/data/in/icudt71l.dat.bz2.

Fixes: nodejs/node#44865
Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: nodejs/node#44870
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
RaisinTen authored and guangwong committed Jan 3, 2023
1 parent b697486 commit af2d9cc
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions tools/update-timezone.mjs
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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');
Expand Down

0 comments on commit af2d9cc

Please sign in to comment.