From f33c47337cbeaa1ff289545b34f51ec92399dea8 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Wed, 8 Feb 2017 10:10:30 +0000 Subject: [PATCH] fix(@angular/cli): Bail out if output path is the root folder pt2 Followup from #4490 --- packages/@angular/cli/tasks/build.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/@angular/cli/tasks/build.ts b/packages/@angular/cli/tasks/build.ts index 699f448509f9..07fce69651e9 100644 --- a/packages/@angular/cli/tasks/build.ts +++ b/packages/@angular/cli/tasks/build.ts @@ -1,6 +1,7 @@ import * as rimraf from 'rimraf'; import * as path from 'path'; const Task = require('../ember-cli/lib/models/task'); +const SilentError = require('silent-error'); import * as webpack from 'webpack'; import { BuildTaskOptions } from '../commands/build'; import { NgCliWebpackConfig } from '../models/webpack-config'; @@ -14,6 +15,9 @@ export default Task.extend({ const project = this.cliProject; const outputPath = runTaskOptions.outputPath || CliConfig.fromProject().config.apps[0].outDir; + if (this.project.root === outputPath) { + throw new SilentError ('Output path MUST not be project root directory!'); + } rimraf.sync(path.resolve(project.root, outputPath)); const webpackConfig = new NgCliWebpackConfig(runTaskOptions).config;