Skip to content

Commit

Permalink
fix(@angular/cli): fix delete path check
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitarora authored and filipesilva committed Jun 7, 2017
1 parent 4f1c37b commit 0a464ea
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/@angular/cli/tasks/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default Task.extend({
const app = getAppFromConfig(runTaskOptions.app);

const outputPath = runTaskOptions.outputPath || app.outDir;
if (this.project.root === outputPath) {
if (this.project.root === path.resolve(outputPath)) {
throw new SilentError('Output path MUST not be project root directory!');
}
if (config.project && config.project.ejected) {
Expand Down
2 changes: 1 addition & 1 deletion packages/@angular/cli/tasks/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export default Task.extend({
const outputPath = runTaskOptions.outputPath || appConfig.outDir;
const force = runTaskOptions.force;

if (project.root === outputPath) {
if (project.root === path.resolve(outputPath)) {
throw new SilentError ('Output path MUST not be project root directory!');
}

Expand Down
2 changes: 1 addition & 1 deletion packages/@angular/cli/tasks/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default Task.extend({
const appConfig = getAppFromConfig(serveTaskOptions.app);

const outputPath = serveTaskOptions.outputPath || appConfig.outDir;
if (this.project.root === outputPath) {
if (this.project.root === path.resolve(outputPath)) {
throw new SilentError('Output path MUST not be project root directory!');
}
if (projectConfig.project && projectConfig.project.ejected) {
Expand Down
17 changes: 17 additions & 0 deletions tests/e2e/tests/commands/build/build-outdir.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {ng} from '../../../utils/process';
import {updateJsonFile} from '../../../utils/project';
import {expectToFail} from '../../../utils/utils';

export default function() {
return Promise.resolve()
.then(() => updateJsonFile('.angular-cli.json', configJson => {
const app = configJson['apps'][0];
app['outDir'] = './';
}))
.then(() => expectToFail(() => ng('build')))
.then(() => expectToFail(() => ng('serve')))
.then(() => expectToFail(() => ng('eject')));
}



0 comments on commit 0a464ea

Please sign in to comment.