Commit 8bf040b 1 parent d76d8fd commit 8bf040b Copy full SHA for 8bf040b
File tree 6 files changed +35
-14
lines changed
6 files changed +35
-14
lines changed Original file line number Diff line number Diff line change @@ -118,6 +118,13 @@ export const baseBuildCommandOptions: any = [
118
118
type : String ,
119
119
aliases : [ 'a' ] ,
120
120
description : 'Specifies app name or index to use.'
121
+ } ,
122
+ {
123
+ name : 'delete-output-path' ,
124
+ type : Boolean ,
125
+ default : true ,
126
+ aliases : [ 'dop' ] ,
127
+ description : 'Delete output path before build.'
121
128
}
122
129
] ;
123
130
Original file line number Diff line number Diff line change @@ -17,5 +17,5 @@ export interface BuildOptions {
17
17
outputHashing ?: string ;
18
18
poll ?: number ;
19
19
app ?: string ;
20
-
20
+ deleteOutputPath ?: boolean ;
21
21
}
Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ export default Task.extend({
27
27
if ( config . project && config . project . ejected ) {
28
28
throw new SilentError ( 'An ejected project cannot use the build command anymore.' ) ;
29
29
}
30
- rimraf . sync ( path . resolve ( project . root , outputPath ) ) ;
30
+ if ( runTaskOptions . deleteOutputPath ) {
31
+ rimraf . sync ( path . resolve ( project . root , outputPath ) ) ;
32
+ }
31
33
32
34
const webpackConfig = new NgCliWebpackConfig ( runTaskOptions , app ) . buildConfig ( ) ;
33
35
const webpackCompiler = webpack ( webpackConfig ) ;
Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ export default Task.extend({
31
31
if ( projectConfig . project && projectConfig . project . ejected ) {
32
32
throw new SilentError ( 'An ejected project cannot use the build command anymore.' ) ;
33
33
}
34
- rimraf . sync ( path . resolve ( this . project . root , outputPath ) ) ;
34
+ if ( serveTaskOptions . deleteOutputPath ) {
35
+ rimraf . sync ( path . resolve ( this . project . root , outputPath ) ) ;
36
+ }
35
37
36
38
const serveDefaults = {
37
39
// default deployUrl to '' on serve to prevent the default from .angular-cli.json
Original file line number Diff line number Diff line change
1
+ import { ng } from '../../utils/process' ;
2
+ import { expectToFail } from '../../utils/utils' ;
3
+ import { deleteFile , expectFileToExist } from '../../utils/fs' ;
4
+ import { getGlobalVariable } from '../../utils/env' ;
5
+
6
+ export default function ( ) {
7
+ // Skip this in ejected tests.
8
+ if ( getGlobalVariable ( 'argv' ) . eject ) {
9
+ return Promise . resolve ( ) ;
10
+ }
11
+
12
+ return ng ( 'build' )
13
+ // This is supposed to fail since there's a missing file
14
+ . then ( ( ) => deleteFile ( 'src/app/app.component.ts' ) )
15
+ // The build fails but we don't delete the output of the previous build.
16
+ . then ( ( ) => expectToFail ( ( ) => ng ( 'build' , '--no-delete-output-path' ) ) )
17
+ . then ( ( ) => expectFileToExist ( 'dist' ) )
18
+ // By default, output path is always cleared.
19
+ . then ( ( ) => expectToFail ( ( ) => ng ( 'build' ) ) )
20
+ . then ( ( ) => expectToFail ( ( ) => expectFileToExist ( 'dist' ) ) ) ;
21
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments