Skip to content

Commit 50170b9

Browse files
committed
fix(@angular/cli): bug fixes on version and global config
1 parent 9c25f74 commit 50170b9

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

packages/@angular/cli/commands/version.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ const VersionCommand = Command.extend({
4343
ngCliVersion = `local (v${pkg.version}, branch: ${gitBranch})`;
4444
}
4545
const config = CliConfig.fromProject();
46-
if (config && config.config.project.version !== pkg.version) {
47-
ngCliVersion += ` [${config.config.project.version}]`;
48-
}
49-
if (config && config.config.project.ejected) {
50-
ngCliVersion += ' (e)';
46+
if (config && config.config && config.config.project) {
47+
if (config.config.project.version !== pkg.version) {
48+
ngCliVersion += ` [${config.config.project.version}]`;
49+
}
50+
if (config.config.project.ejected) {
51+
ngCliVersion += ' (e)';
52+
}
5153
}
5254

5355
if (projPkg) {

packages/@angular/cli/models/config.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ export class CliConfig extends CliConfigBase<ConfigInterface> {
4747
}
4848

4949
static fromGlobal(): CliConfig {
50-
const globalConfigPath = path.join(getUserHome(), CLI_CONFIG_FILE_NAME);
50+
let globalConfigPath = path.join(getUserHome(), CLI_CONFIG_FILE_NAME);
51+
const altGlobalConfigPath = path.join(getUserHome(), CLI_CONFIG_FILE_NAME_ALT);
52+
if (!fs.existsSync(globalConfigPath) && fs.existsSync(altGlobalConfigPath)) {
53+
globalConfigPath = altGlobalConfigPath;
54+
}
5155

5256
const cliConfig = CliConfigBase.fromConfigPath<ConfigInterface>(globalConfigPath);
5357

@@ -81,12 +85,16 @@ export class CliConfig extends CliConfigBase<ConfigInterface> {
8185

8286
static fromProject(): CliConfig {
8387
const configPath = this.configFilePath();
84-
const globalConfigPath = path.join(getUserHome(), CLI_CONFIG_FILE_NAME);
85-
8688
if (!configPath) {
8789
return null;
8890
}
8991

92+
let globalConfigPath = path.join(getUserHome(), CLI_CONFIG_FILE_NAME);
93+
const altGlobalConfigPath = path.join(getUserHome(), CLI_CONFIG_FILE_NAME_ALT);
94+
if (!fs.existsSync(globalConfigPath) && fs.existsSync(altGlobalConfigPath)) {
95+
globalConfigPath = altGlobalConfigPath;
96+
}
97+
9098
const cliConfig = CliConfigBase.fromConfigPath<ConfigInterface>(
9199
CliConfig.configFilePath(), [globalConfigPath]);
92100

0 commit comments

Comments
 (0)