Skip to content

Commit 6141e6f

Browse files
Broccohansl
authored andcommitted
fix(@angular/cli): Update in project logic
fixes #10594
1 parent 73a1588 commit 6141e6f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

packages/@angular/cli/utilities/project.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ import * as fs from 'fs';
22
import * as os from 'os';
33
import * as path from 'path';
44
import { findUp } from './find-up';
5+
import { normalize } from '@angular-devkit/core';
56

67
export function insideProject(): boolean {
7-
const possibleConfigFiles = ['angular.json', '.angular.json'];
8-
9-
return findUp(possibleConfigFiles, process.cwd()) !== null;
8+
return getProjectDetails() !== null;
109
}
1110

1211
export interface ProjectDetails {
@@ -31,7 +30,7 @@ export function getProjectDetails(): ProjectDetails | null {
3130
const possibleDir = path.dirname(configFilePath);
3231

3332
const homedir = os.homedir();
34-
if (possibleDir === homedir) {
33+
if (normalize(possibleDir) === normalize(homedir)) {
3534
const packageJsonPath = path.join(possibleDir, 'package.json');
3635
if (!fs.existsSync(packageJsonPath)) {
3736
// No package.json
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {writeFile, deleteFile} from '../../utils/fs';
2+
import {ng} from '../../utils/process';
3+
import * as os from 'os';
4+
import {join} from 'path';
5+
6+
7+
export default function() {
8+
const homedir = os.homedir();
9+
const globalConfigPath = join(homedir, '.angular.json');
10+
return Promise.resolve()
11+
.then(() => writeFile(globalConfigPath, '{"version":1}'))
12+
.then(() => process.chdir(homedir))
13+
.then(() => ng('new', 'proj-name', '--dry-run'))
14+
.then(() => deleteFile(globalConfigPath));
15+
}

0 commit comments

Comments
 (0)