Skip to content

Commit 7c288c8

Browse files
committed
fix(@angular/cli): add package manager name and version in ng version output
(cherry picked from commit 5558047)
1 parent 81471c0 commit 7c288c8

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/angular/cli/commands/version-impl.ts

+14
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8+
import { execSync } from 'child_process';
89
import * as path from 'path';
910
import { Command } from '../models/command';
1011
import { colors } from '../utilities/color';
12+
import { getPackageManager } from '../utilities/package-manager';
1113
import { Schema as VersionCommandSchema } from './version';
1214

1315
interface PartialPackageInfo {
@@ -105,6 +107,7 @@ export class VersionCommand extends Command<VersionCommandSchema> {
105107
`
106108
Angular CLI: ${ngCliVersion}
107109
Node: ${process.versions.node}
110+
Package Manager: ${await this.getPackageManager()}
108111
OS: ${process.platform} ${process.arch}
109112
110113
Angular: ${angularCoreVersion}
@@ -163,4 +166,15 @@ export class VersionCommand extends Command<VersionCommandSchema> {
163166

164167
return version || '<error>';
165168
}
169+
170+
private async getPackageManager(): Promise<string> {
171+
try {
172+
const manager = await getPackageManager(this.context.root);
173+
const version = execSync(`${manager} --version`, { encoding: 'utf8', stdio: 'pipe' }).trim();
174+
175+
return `${manager} ${version}`;
176+
} catch {
177+
return '<error>';
178+
}
179+
}
166180
}

0 commit comments

Comments
 (0)