Skip to content

Commit 0a464ea

Browse files
sumitarorafilipesilva
authored andcommitted
fix(@angular/cli): fix delete path check
1 parent 4f1c37b commit 0a464ea

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

packages/@angular/cli/tasks/build.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default Task.extend({
2020
const app = getAppFromConfig(runTaskOptions.app);
2121

2222
const outputPath = runTaskOptions.outputPath || app.outDir;
23-
if (this.project.root === outputPath) {
23+
if (this.project.root === path.resolve(outputPath)) {
2424
throw new SilentError('Output path MUST not be project root directory!');
2525
}
2626
if (config.project && config.project.ejected) {

packages/@angular/cli/tasks/eject.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ export default Task.extend({
397397
const outputPath = runTaskOptions.outputPath || appConfig.outDir;
398398
const force = runTaskOptions.force;
399399

400-
if (project.root === outputPath) {
400+
if (project.root === path.resolve(outputPath)) {
401401
throw new SilentError ('Output path MUST not be project root directory!');
402402
}
403403

packages/@angular/cli/tasks/serve.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default Task.extend({
2525
const appConfig = getAppFromConfig(serveTaskOptions.app);
2626

2727
const outputPath = serveTaskOptions.outputPath || appConfig.outDir;
28-
if (this.project.root === outputPath) {
28+
if (this.project.root === path.resolve(outputPath)) {
2929
throw new SilentError('Output path MUST not be project root directory!');
3030
}
3131
if (projectConfig.project && projectConfig.project.ejected) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {ng} from '../../../utils/process';
2+
import {updateJsonFile} from '../../../utils/project';
3+
import {expectToFail} from '../../../utils/utils';
4+
5+
export default function() {
6+
return Promise.resolve()
7+
.then(() => updateJsonFile('.angular-cli.json', configJson => {
8+
const app = configJson['apps'][0];
9+
app['outDir'] = './';
10+
}))
11+
.then(() => expectToFail(() => ng('build')))
12+
.then(() => expectToFail(() => ng('serve')))
13+
.then(() => expectToFail(() => ng('eject')));
14+
}
15+
16+
17+

0 commit comments

Comments
 (0)