From 02a3d7b715f4069650389ba26a3601747e67d9c2 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 24 Oct 2022 14:18:29 +0000 Subject: [PATCH] fix(@angular/cli): skip node.js compatibility checks when running completion A warning at this stage could cause a broken source action (`source <(ng completion script)`) when in the shell init script. Closes #24104 (cherry picked from commit 1e4dbfdf4afb03a215db620fb0e0db6f86cdac63) --- packages/angular/cli/bin/ng.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/angular/cli/bin/ng.js b/packages/angular/cli/bin/ng.js index 5d5744b4c0ed..ce7e50de2090 100755 --- a/packages/angular/cli/bin/ng.js +++ b/packages/angular/cli/bin/ng.js @@ -20,6 +20,16 @@ try { process.title = 'ng'; } +const rawCommandName = process.argv[2]; + +if (rawCommandName === '--get-yargs-completions' || rawCommandName === 'completion') { + // Skip Node.js supported checks when running ng completion. + // A warning at this stage could cause a broken source action (`source <(ng completion script)`) when in the shell init script. + require('./bootstrap'); + + return; +} + // This node version check ensures that extremely old versions of node are not used. // These may not support ES2015 features such as const/let/async/await/etc. // These would then crash with a hard to diagnose error message.