@@ -6,7 +6,7 @@ export class Options {
66 private static NONDASHED_OPTION_REGEX = / ( .+ ?) [ - ] ( [ a - z A - Z ] ) ( .* ) / ;
77
88 private optionsWhiteList = [ "ui" , "recursive" , "reporter" , "require" , "timeout" , "_" , "$0" ] ; // These options shouldn't be validated
9- public argv : IYargArgv ;
9+ private yargsArgv : yargs . Argv ;
1010 private globalOptions : IDictionary < IDashedOption > = {
1111 log : { type : OptionType . String , hasSensitiveValue : false } ,
1212 verbose : { type : OptionType . Boolean , alias : "v" , hasSensitiveValue : false } ,
@@ -19,24 +19,23 @@ export class Options {
1919 _ : { type : OptionType . String , hasSensitiveValue : false }
2020 } ;
2121
22+ public argv : yargs . Arguments ;
2223 public options : IDictionary < IDashedOption > ;
2324
24- public setupOptions ( projectData : IProjectData , commandSpecificDashedOptions ?: IDictionary < IDashedOption > ) : void {
25+ public setupOptions ( commandSpecificDashedOptions ?: IDictionary < IDashedOption > ) : void {
2526 if ( commandSpecificDashedOptions ) {
2627 _ . extend ( this . options , commandSpecificDashedOptions ) ;
2728 this . setArgv ( ) ;
2829 }
2930
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 ) {
3135 this . $errors . failWithoutHelp ( "The options --release and --hmr cannot be used simultaneously." ) ;
3236 }
3337
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 ) {
4039 this . argv . hmr = ! this . argv . release ;
4140 }
4241
@@ -111,7 +110,7 @@ export class Options {
111110 pluginName : { type : OptionType . String , hasSensitiveValue : false } ,
112111 includeTypeScriptDemo : { type : OptionType . String , hasSensitiveValue : false } ,
113112 includeAngularDemo : { type : OptionType . String , hasSensitiveValue : false } ,
114- hmr : { type : OptionType . Boolean , hasSensitiveValue : false } ,
113+ hmr : { type : OptionType . Boolean , hasSensitiveValue : false , default : true } ,
115114 collection : { type : OptionType . String , alias : "c" , hasSensitiveValue : false } ,
116115 json : { type : OptionType . Boolean , hasSensitiveValue : false } ,
117116 avd : { type : OptionType . String , hasSensitiveValue : true } ,
@@ -159,8 +158,8 @@ export class Options {
159158 return this . argv [ optionName ] ;
160159 }
161160
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 ) ;
164163 const parsed = Object . create ( null ) ;
165164 // 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".
166165 _ . each ( _ . keys ( this . argv ) , optionName => {
@@ -251,12 +250,13 @@ export class Options {
251250 opts [ this . getDashedOptionName ( key ) ] = value ;
252251 } ) ;
253252
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 ;
255255
256256 // For backwards compatibility
257257 // Previously profileDir had a default option and calling `this.$options.profileDir` always returned valid result.
258258 // 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 } ) ;
260260 this . argv . profileDir = this . argv [ "profile-dir" ] = this . $settingsService . getProfileDir ( ) ;
261261
262262 // if justlaunch is set, it takes precedence over the --watch flag and the default true value
0 commit comments