base: fail loudly when extract_locales.js runs outside the repo root - #2123
Open
dajiaohuang wants to merge 1 commit into
Open
dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
The `source_paths` in `base/tools/extract_locales.js` are relative to the current working directory, and a missing path is skipped with `continue`. Run from anywhere but the repository root - the readme's own build steps leave you in `paint/` - every path is skipped, so nothing is extracted, yet the script exits 0 with no output at all. The relative `locale_path` means no file is written either, so the command looks like it worked. Track whether any source path was found and exit non-zero with a message when none was, matching the existing "Locale code not set!" error path. Behaviour from the repository root is unchanged: the generated locale is byte-identical.
dajiaohuang
force-pushed
the
fix/extract-locales-guard
branch
from
September 11, 2026 10:52
ac2f7ee to
4e3fb03
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2122.
source_pathsandlocale_pathinbase/tools/extract_locales.jsare relative to the current working directory, and a missing source path is skipped withcontinue. Run from anywhere but the repository root, every path is skipped: nothing is extracted, nothing is reported, and the script still exits 0. Sincelocale_pathis relative as well, the output directory normally does not exist at that location, so no file is written either - the command looks like it succeeded.This mirrors the existing
"Locale code not set!"guard at the top of the same file.Verification
Scratch tree:
paint/sources/demo.cwith twotr("...")strings,paint/sources/nodes_material/n.cwith one, and an existingpaint/assets/locale/zz.jsonholding a real translation plus a stale key. Driven with the committedbase/tools/bin/windows_x64/amake.exe.Run from
paint/:zz.jsonNo source paths found - run this script from the repository root.Run from the repository root - the supported path:
So the correct-cwd behaviour is unchanged; only the silent failure now reports itself.
std.exit(1)is used rather than the barestd.exit()at line 11 so the failure is detectable from a script.Single file, guard only - no extraction or output-format change.
🤖 Generated with Claude Code