@@ -6,7 +6,7 @@ export class Options {
6
6
private static NONDASHED_OPTION_REGEX = / ( .+ ?) [ - ] ( [ a - z A - Z ] ) ( .* ) / ;
7
7
8
8
private optionsWhiteList = [ "ui" , "recursive" , "reporter" , "require" , "timeout" , "_" , "$0" ] ; // These options shouldn't be validated
9
- public argv : IYargArgv ;
9
+ private yargsArgv : yargs . Argv ;
10
10
private globalOptions : IDictionary < IDashedOption > = {
11
11
log : { type : OptionType . String , hasSensitiveValue : false } ,
12
12
verbose : { type : OptionType . Boolean , alias : "v" , hasSensitiveValue : false } ,
@@ -19,24 +19,23 @@ export class Options {
19
19
_ : { type : OptionType . String , hasSensitiveValue : false }
20
20
} ;
21
21
22
+ public argv : yargs . Arguments ;
22
23
public options : IDictionary < IDashedOption > ;
23
24
24
- public setupOptions ( projectData : IProjectData , commandSpecificDashedOptions ?: IDictionary < IDashedOption > ) : void {
25
+ public setupOptions ( commandSpecificDashedOptions ?: IDictionary < IDashedOption > ) : void {
25
26
if ( commandSpecificDashedOptions ) {
26
27
_ . extend ( this . options , commandSpecificDashedOptions ) ;
27
28
this . setArgv ( ) ;
28
29
}
29
30
30
- if ( this . argv . release && this . argv . hmr ) {
31
+ this . argv . bundle = "webpack" ;
32
+
33
+ // Check if the user has explicitly provide --hmr and --release options from command line
34
+ if ( this . yargsArgv . argv . release && this . yargsArgv . argv . hmr ) {
31
35
this . $errors . failWithoutHelp ( "The options --release and --hmr cannot be used simultaneously." ) ;
32
36
}
33
37
34
- this . argv . bundle = "webpack" ;
35
-
36
- const parsed = require ( "yargs-parser" ) ( process . argv . slice ( 2 ) , { 'boolean-negation' : false } ) ;
37
- // --no-hmr -> hmr: false or --hmr false -> hmr: 'false'
38
- const noHmr = parsed && ( parsed . hmr === false || parsed . hmr === 'false' ) ;
39
- if ( ! noHmr ) {
38
+ if ( this . argv . hmr ) {
40
39
this . argv . hmr = ! this . argv . release ;
41
40
}
42
41
@@ -111,7 +110,7 @@ export class Options {
111
110
pluginName : { type : OptionType . String , hasSensitiveValue : false } ,
112
111
includeTypeScriptDemo : { type : OptionType . String , hasSensitiveValue : false } ,
113
112
includeAngularDemo : { type : OptionType . String , hasSensitiveValue : false } ,
114
- hmr : { type : OptionType . Boolean , hasSensitiveValue : false } ,
113
+ hmr : { type : OptionType . Boolean , hasSensitiveValue : false , default : true } ,
115
114
collection : { type : OptionType . String , alias : "c" , hasSensitiveValue : false } ,
116
115
json : { type : OptionType . Boolean , hasSensitiveValue : false } ,
117
116
avd : { type : OptionType . String , hasSensitiveValue : true } ,
@@ -159,8 +158,8 @@ export class Options {
159
158
return this . argv [ optionName ] ;
160
159
}
161
160
162
- public validateOptions ( commandSpecificDashedOptions ?: IDictionary < IDashedOption > , projectData ?: IProjectData ) : void {
163
- this . setupOptions ( projectData , commandSpecificDashedOptions ) ;
161
+ public validateOptions ( commandSpecificDashedOptions ?: IDictionary < IDashedOption > ) : void {
162
+ this . setupOptions ( commandSpecificDashedOptions ) ;
164
163
const parsed = Object . create ( null ) ;
165
164
// DO NOT REMOVE { } as when they are missing and some of the option values is false, the each stops as it thinks we have set "return false".
166
165
_ . each ( _ . keys ( this . argv ) , optionName => {
@@ -251,12 +250,13 @@ export class Options {
251
250
opts [ this . getDashedOptionName ( key ) ] = value ;
252
251
} ) ;
253
252
254
- this . argv = yargs ( process . argv . slice ( 2 ) ) . options ( opts ) . argv ;
253
+ this . yargsArgv = yargs ( process . argv . slice ( 2 ) ) ;
254
+ this . argv = this . yargsArgv . options ( < any > opts ) . argv ;
255
255
256
256
// For backwards compatibility
257
257
// Previously profileDir had a default option and calling `this.$options.profileDir` always returned valid result.
258
258
// Now the profileDir should be used from $settingsService, but ensure the `this.$options.profileDir` returns the same value.
259
- this . $settingsService . setSettings ( { profileDir : this . argv . profileDir } ) ;
259
+ this . $settingsService . setSettings ( { profileDir : < string > this . argv . profileDir } ) ;
260
260
this . argv . profileDir = this . argv [ "profile-dir" ] = this . $settingsService . getProfileDir ( ) ;
261
261
262
262
// if justlaunch is set, it takes precedence over the --watch flag and the default true value
0 commit comments