Skip to content

Commit ba4ddf1

Browse files
committed
fix(@angular/cli): Fixing global path issue
1 parent b918603 commit ba4ddf1

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,10 @@ export class CliConfig extends CliConfigBase<ConfigInterface> {
9595

9696
static fromProject(projectPath?: string): CliConfig {
9797
const configPath = this.configFilePath(projectPath);
98-
if (!configPath || configPath === this.globalConfigFilePath()) {
99-
return null;
98+
99+
if (!configPath ||
100+
(configPath === this.globalConfigFilePath() && process.cwd() !== path.dirname(configPath))) {
101+
return null;
100102
}
101103
if (configCacheMap.has(configPath)) {
102104
return configCacheMap.get(configPath);

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ export class CliConfig<JsonType> {
7474
? ts.sys.readFile(configPath)
7575
: '{}';
7676
const schemaContent = fs.readFileSync(DEFAULT_CONFIG_SCHEMA_PATH, 'utf-8');
77-
const otherContents = otherPath
78-
.map(path => fs.existsSync(path) && ts.sys.readFile(path))
79-
.filter(content => !!content);
77+
78+
let otherContents = new Array<string>();
79+
if (configPath !== otherPath[0]) {
80+
otherContents = otherPath
81+
.map(path => fs.existsSync(path) && ts.sys.readFile(path))
82+
.filter(content => !!content);
83+
}
8084

8185
let content: T;
8286
let schema: Object;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {ng} from '../../utils/process';
2+
import {deleteFile} from '../../utils/fs';
3+
import {expectToFail} from '../../utils/utils';
4+
5+
export default function() {
6+
return deleteFile('.angular-cli.json')
7+
.then(() => expectToFail(() => ng('generate', 'class', 'hello')));
8+
}

0 commit comments

Comments
 (0)