File tree Expand file tree Collapse file tree 4 files changed +20
-8
lines changed Expand file tree Collapse file tree 4 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,15 @@ exports.setOptions = function (optimist) {
13
13
optimist . describe ( 's' , '使用sourcemap' ) ;
14
14
optimist . alias ( 'g' , 'group' ) ;
15
15
optimist . describe ( 'g' , 'exports 分组' ) ;
16
+ optimist . alias ( 'c' , 'clean' ) ;
17
+ optimist . describe ( 'c' , '打包前清空输出目录' ) ;
16
18
} ;
17
19
18
20
exports . run = function ( options ) {
19
21
var cwd = options . cwd ,
20
22
min = options . m || options . min || false ,
21
23
lint = options . l || options . lint || false ,
24
+ clean = options . c || options . clean || false ,
22
25
group = options . g || options . group ,
23
26
sourcemap = options . s || options . sourcemap ,
24
27
project = this . project ;
@@ -35,7 +38,8 @@ exports.run = function (options) {
35
38
project . pack ( {
36
39
lint : lint ,
37
40
min : min ,
38
- sourcemap : sourcemap
41
+ sourcemap : sourcemap ,
42
+ clean : clean
39
43
} , function ( err , stats ) {
40
44
if ( err ) {
41
45
if ( err !== true ) {
Original file line number Diff line number Diff line change @@ -261,9 +261,11 @@ var Project = function () {
261
261
config . devtool = opt . sourcemap ;
262
262
}
263
263
264
- try {
265
- childProcess . execSync ( 'rm -rf ' + config . output . path ) ;
266
- } catch ( e ) { }
264
+ if ( opt . clean ) {
265
+ try {
266
+ childProcess . execSync ( 'rm -rf ' + config . output . path ) ;
267
+ } catch ( e ) { }
268
+ }
267
269
268
270
config . plugins . push ( new ProgressBarPlugin ( ) ) ;
269
271
Original file line number Diff line number Diff line change @@ -13,12 +13,15 @@ exports.setOptions = (optimist) => {
13
13
optimist . describe ( 's' , '使用sourcemap' ) ;
14
14
optimist . alias ( 'g' , 'group' ) ;
15
15
optimist . describe ( 'g' , 'exports 分组' ) ;
16
+ optimist . alias ( 'c' , 'clean' ) ;
17
+ optimist . describe ( 'c' , '打包前清空输出目录' ) ;
16
18
} ;
17
19
18
20
exports . run = function ( options ) {
19
21
let cwd = options . cwd ,
20
22
min = options . m || options . min || false ,
21
23
lint = options . l || options . lint || false ,
24
+ clean = options . c || options . clean || false ,
22
25
group = options . g || options . group ,
23
26
sourcemap = options . s || options . sourcemap ,
24
27
project = this . project ;
@@ -35,7 +38,8 @@ exports.run = function (options) {
35
38
project . pack ( {
36
39
lint : lint ,
37
40
min : min ,
38
- sourcemap : sourcemap
41
+ sourcemap : sourcemap ,
42
+ clean : clean
39
43
} , ( err , stats ) => {
40
44
if ( err ) {
41
45
if ( err !== true ) {
Original file line number Diff line number Diff line change @@ -232,9 +232,11 @@ class Project {
232
232
config . devtool = opt . sourcemap
233
233
}
234
234
235
- try {
236
- childProcess . execSync ( 'rm -rf ' + config . output . path ) ;
237
- } catch ( e ) { }
235
+ if ( opt . clean ) {
236
+ try {
237
+ childProcess . execSync ( 'rm -rf ' + config . output . path ) ;
238
+ } catch ( e ) { }
239
+ }
238
240
239
241
config . plugins . push ( new ProgressBarPlugin ( ) )
240
242
You can’t perform that action at this time.
0 commit comments