Skip to content

Commit

Permalink
fix(@angular/cli): add package manager name and version in `ng versio…
Browse files Browse the repository at this point in the history
…n` output

(cherry picked from commit 5558047)
  • Loading branch information
alan-agius4 committed Apr 22, 2021
1 parent 81471c0 commit 7c288c8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/angular/cli/commands/version-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { execSync } from 'child_process';
import * as path from 'path';
import { Command } from '../models/command';
import { colors } from '../utilities/color';
import { getPackageManager } from '../utilities/package-manager';
import { Schema as VersionCommandSchema } from './version';

interface PartialPackageInfo {
Expand Down Expand Up @@ -105,6 +107,7 @@ export class VersionCommand extends Command<VersionCommandSchema> {
`
Angular CLI: ${ngCliVersion}
Node: ${process.versions.node}
Package Manager: ${await this.getPackageManager()}
OS: ${process.platform} ${process.arch}
Angular: ${angularCoreVersion}
Expand Down Expand Up @@ -163,4 +166,15 @@ export class VersionCommand extends Command<VersionCommandSchema> {

return version || '<error>';
}

private async getPackageManager(): Promise<string> {
try {
const manager = await getPackageManager(this.context.root);
const version = execSync(`${manager} --version`, { encoding: 'utf8', stdio: 'pipe' }).trim();

return `${manager} ${version}`;
} catch {
return '<error>';
}
}
}

0 comments on commit 7c288c8

Please sign in to comment.