Speed up pre-commit localization check#22076
Merged
Merged
Conversation
…it localization extraction
409633b to
4c580ed
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR speeds up the repo’s pre-commit workflow by adding a --precommit mode to scripts/localization-extract.js that only extracts localization for extensions impacted by staged localization inputs, while preserving the existing full-extraction behavior for npm run localization. It also updates the Husky hook to use the new mode and adds timing notes documenting the improvement.
Changes:
- Add staged-file detection and
--precommitexecution path toscripts/localization-extract.js. - Update
.husky/pre-committo runnode scripts/localization-extract.js --precommit. - Add
PRECOMMIT_TIMINGS.mddocumenting before/after timings and hook behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| scripts/localization-extract.js | Adds --precommit mode that scopes localization extraction to affected extensions based on staged files. |
| .husky/pre-commit | Switches localization step to the new staged-only mode for faster pre-commit runs. |
| PRECOMMIT_TIMINGS.md | Documents measured pre-commit timing improvements and current/updated hook behavior. |
Comment on lines
+23
to
+33
| const EXTENSION_INPUTS = { | ||
| mssql: ["extensions/mssql/src/", "extensions/mssql/package.nls.json"], | ||
| "sql-database-projects": [ | ||
| "extensions/sql-database-projects/src/", | ||
| "extensions/sql-database-projects/package.nls.json", | ||
| ], | ||
| "data-workspace": [ | ||
| "extensions/data-workspace/src/", | ||
| "extensions/data-workspace/package.nls.json", | ||
| ], | ||
| }; |
| const LOCALIZATION_SCRIPT_INPUTS = [ | ||
| "scripts/localization-extract.js", | ||
| "scripts/file-utils.js", | ||
| "scripts/terminal-logger.js", |
| return output | ||
| .toString("utf8") | ||
| .split("\0") | ||
| .map((file) => file.replace(/\\/g, "/").trim()) |
| async function extractLocalizationForPrecommit() { | ||
| const affectedExtensions = getAffectedExtensionsForPrecommit(); | ||
| if (!affectedExtensions.length) { | ||
| console.log("No staged localization inputs; skipping localization extraction."); |
PR Changes
|
Benjin
reviewed
May 7, 2026
| "scripts/terminal-logger.js", | ||
| ]; | ||
|
|
||
| function getStagedFiles() { |
Contributor
There was a problem hiding this comment.
How is the linter being limited to just staged files? something that could be shared between the two?
Benjin
approved these changes
May 7, 2026
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.
Summary
--precommitmode toscripts/localization-extract.js.npm run localizationusage.Performance
Measured on Windows/PowerShell from the repository root with no staged localization inputs.
npm run localizationvsnode scripts/localization-extract.js --precommit.husky/pre-commitnode scripts/ensure-crlf.jsnpm run precommit/lint-staged --quietValidation
node scripts/localization-extract.js --precommit.husky/pre-commitvia Git Bashshnpx prettier --check scripts/localization-extract.jsgit diff --check