Skip to content

Commit b7317b1

Browse files
authored
fix(ng-dev): replace bazel run @npm2//:sync with bazel sync --only=repo (#2586)
In certain scenarios, running `bazel run @npm2//:sync` does not reliably update the aspect lock files. For example: ``` # Update the version in package.json $ yarn bazel run @npm2//:sync # Lock file is updated $ git restore .aspect $ yarn bazel run @npm2//:sync # Lock file is NOT updated ``` Switching to `bazel sync --only=repo` guarantees that the lock file is consistently updated. More context: https://angular-team.slack.com/archives/C042EU9T5/p1739398554132249
1 parent 389821c commit b7317b1

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

ng-dev/release/publish/external-commands.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,23 +259,21 @@ export abstract class ExternalCommands {
259259
}
260260

261261
/**
262-
* Invokes the `yarn bazel run @npm2//:sync` command in order
262+
* Invokes the `yarn bazel sync --only=repo` command in order
263263
* to refresh Aspect lock files.
264264
*/
265265
static async invokeBazelUpdateAspectLockFiles(projectDir: string): Promise<void> {
266266
const spinner = new Spinner('Updating Aspect lock files');
267-
268267
try {
269-
await ChildProcess.spawn(getBazelBin(), ['run', '@npm2//:sync'], {
268+
await ChildProcess.spawn(getBazelBin(), ['sync', '--only=repo'], {
270269
cwd: projectDir,
271270
mode: 'silent',
272271
});
273272
} catch (e) {
274-
// Note: Gracefully handling these errors because `sync` command
275-
// alway exits with a non-zero exit code.
276-
Log.debug(e);
273+
Log.error(e);
274+
Log.error(' ✘ An error occurred while updating Aspect lock files.');
275+
throw new FatalReleaseActionError();
277276
}
278-
279277
spinner.success(green(' Updated Aspect `rules_js` lock files.'));
280278
}
281279
}

0 commit comments

Comments
 (0)