@@ -53,7 +53,8 @@ var cli = meow({
5353 'recursive' ,
5454 'source-map-embed' ,
5555 'source-map-contents' ,
56- 'source-comments'
56+ 'source-comments' ,
57+ 'watch'
5758 ] ,
5859 string : [
5960 'functions' ,
@@ -64,8 +65,7 @@ var cli = meow({
6465 'output' ,
6566 'output-style' ,
6667 'precision' ,
67- 'source-map-root' ,
68- 'watch'
68+ 'source-map-root'
6969 ] ,
7070 alias : {
7171 c : 'source-comments' ,
@@ -82,7 +82,8 @@ var cli = meow({
8282 'indent-width' : 2 ,
8383 linefeed : 'lf' ,
8484 'output-style' : 'nested' ,
85- precision : 5
85+ precision : 5 ,
86+ recursive : true
8687 }
8788} ) ;
8889
@@ -139,7 +140,7 @@ function getEmitter() {
139140 */
140141
141142function getOptions ( args , options ) {
142- options . src = options . watch ? options . watch : args [ 0 ] ;
143+ options . src = args [ 0 ] ;
143144
144145 if ( args [ 1 ] ) {
145146 options . dest = path . resolve ( process . cwd ( ) , args [ 1 ] ) ;
@@ -161,26 +162,20 @@ function getOptions(args, options) {
161162 */
162163
163164function watch ( options , emitter ) {
164- var dir = options . watch ;
165- var gaze = new Gaze ( ) ;
166-
167- if ( dir === true ) {
168- dir = [ ] ;
169- } else if ( ! Array . isArray ( dir ) ) {
170- dir = [ dir ] ;
165+ var glob = options . recursive ? '**/*.{sass,scss}' : '*.{sass,scss}' ;
166+ var src = isSassFile ( options . src ) ? options . src : path . join ( options . src , glob ) ;
167+ var graph = grapher . parseDir ( path . resolve ( path . dirname ( src ) ) , { loadPaths : options . includePath } ) ;
168+ var watch = [ ] ;
169+
170+ // Add all files to watch list
171+ for ( var i in graph . index ) {
172+ watch . push ( i ) ;
171173 }
172174
173- dir . push ( options . src ) ;
174- dir = dir . map ( function ( d ) {
175- var glob = options . recursive ? '**/*.{sass,scss}' : '*.{sass,scss}' ;
176- return isSassFile ( d ) ? d : path . join ( d , glob ) ;
177- } ) ;
178-
179- gaze . add ( dir ) ;
175+ var gaze = new Gaze ( ) ;
176+ gaze . add ( watch ) ;
180177 gaze . on ( 'error' , emitter . emit . bind ( emitter , 'error' ) ) ;
181178
182- var graph = grapher . parseDir ( options . src , { loadPaths : options . includePath } ) ;
183-
184179 gaze . on ( 'changed' , function ( file ) {
185180 var files = [ file ] ;
186181 graph . visitAncestors ( file , function ( parent ) {
0 commit comments