Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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 -
RaisinTen#2 which updates
deps/icu-small/source/data/in/icudt71l.dat.bz2.

Fixes: #44865
Signed-off-by: Darshan Sen <[email protected]>
  • Loading branch information
RaisinTen committed Oct 3, 2022
commit 0210498f9ec703a322f73cdcc868ddf6294aa611
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/' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be an issue if file contains "weird" characters?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe but that's never supposed to happen because file is always gonna be one of

const fileNames = [
'zoneinfo64.res',
'windowsZones.res',
'timezoneTypes.res',
'metaZones.res',
];
and I think this list is unlikely to change.

rmSync(`deps/icu-small/source/data/in/${file}`);
});
execSync('bzip2 -z deps/icu-small/source/data/in/icudt*.dat');
Expand Down