@@ -2,7 +2,7 @@ var path = require("path");
22var fs = require ( "fs" ) ;
33fs . existsSync = fs . existsSync || path . existsSync ;
44var resolve = require ( "enhanced-resolve" ) ;
5- var interpret = require ( ' interpret' ) ;
5+ var interpret = require ( " interpret" ) ;
66
77module . exports = function ( optimist , argv , convertOptions ) {
88
@@ -73,18 +73,37 @@ module.exports = function(optimist, argv, convertOptions) {
7373 }
7474
7575 if ( argv . context ) {
76- options . context = path . resolve ( argv . context )
76+ options . context = path . resolve ( argv . context ) ;
7777 }
7878 if ( ! options . context ) {
7979 options . context = process . cwd ( ) ;
8080 }
8181
8282 if ( argv [ "watch" ] ) {
83- options . watch = true ;
83+ if ( options . watchDelay ) {
84+ console . warn ( "watchDelay is deprecated: Use 'watch.aggregateTimeout' instead." ) ;
85+ options . watch = options . watch || { } ;
86+ options . watch . aggregateTimeout = options . watchDelay ;
87+ }
88+ options . doWatch = true ;
8489 }
8590
8691 if ( argv [ "watch-delay" ] ) {
87- options . watchDelay = + argv [ "watch-delay" ] ;
92+ options . watch = options . watch || { } ;
93+ options . watch . aggregateTimeout = + argv [ "watch-delay" ] ;
94+ }
95+
96+ if ( argv [ "watch-aggregate-timeout" ] ) {
97+ options . watch = options . watch || { } ;
98+ options . watch . aggregateTimeout = + argv [ "watch-aggregate-timeout" ] ;
99+ }
100+
101+ if ( argv [ "watch-poll" ] ) {
102+ options . watch = options . watch || { } ;
103+ if ( typeof argv [ "watch-poll" ] !== "boolean" )
104+ options . watch . poll = + argv [ "watch-poll" ] ;
105+ else
106+ options . watch . poll = true ;
88107 }
89108
90109 function processOptions ( options ) {
@@ -97,7 +116,7 @@ module.exports = function(optimist, argv, convertOptions) {
97116 if ( finalize ) {
98117 finalize ( ) ;
99118 }
100- } else if ( typeof argv [ name ] != "undefined" ) {
119+ } else if ( typeof argv [ name ] !== "undefined" ) {
101120 if ( init ) {
102121 init ( ) ;
103122 }
@@ -114,7 +133,7 @@ module.exports = function(optimist, argv, convertOptions) {
114133 if ( i < 0 ) {
115134 return fn ( null , content , idx ) ;
116135 } else {
117- return fn ( content . substr ( 0 , i ) , content . substr ( i + 1 ) , idx ) ;
136+ return fn ( content . substr ( 0 , i ) , content . substr ( i + 1 ) , idx ) ;
118137 }
119138 } , init , finalize ) ;
120139 }
@@ -283,11 +302,6 @@ module.exports = function(optimist, argv, convertOptions) {
283302 } ) ;
284303
285304 mapArgToBooleanInverse ( "cache" ) ;
286- mapArgToBoolean ( "watch" ) ;
287-
288- ifArg ( "watch-delay" , function ( value ) {
289- options . watchDelay = value ;
290- } ) ;
291305
292306 ifBooleanArg ( "hot" , function ( ) {
293307 ensureArray ( options , "plugins" ) ;
@@ -464,7 +478,7 @@ module.exports = function(optimist, argv, convertOptions) {
464478 addTo ( "main" , content ) ;
465479 }
466480 } else {
467- addTo ( content . substr ( 0 , i ) , content . substr ( i + 1 ) ) ;
481+ addTo ( content . substr ( 0 , i ) , content . substr ( i + 1 ) ) ;
468482 }
469483 } ) ;
470484 }
0 commit comments