File tree Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,8 @@ Promise.resolve()
7979
8080 input = i
8181
82+ truncateDestinationFile ( )
83+
8284 return files ( input )
8385 } )
8486 . then ( results => {
@@ -97,11 +99,15 @@ Promise.resolve()
9799 . on ( 'change' , file => {
98100 let recompile = [ ]
99101
100- if ( ~ input . indexOf ( file ) ) recompile . push ( file )
102+ if ( ! shouldAppendCSS ( ) ) {
103+ if ( ~ input . indexOf ( file ) ) recompile . push ( file )
101104
102- recompile = recompile . concat (
103- depGraph . dependantsOf ( file ) . filter ( file => ~ input . indexOf ( file ) )
104- )
105+ recompile = recompile . concat (
106+ depGraph . dependantsOf ( file ) . filter ( file => ~ input . indexOf ( file ) ) ,
107+ )
108+ } else {
109+ truncateDestinationFile ( )
110+ }
105111
106112 if ( ! recompile . length ) recompile = input
107113
@@ -307,3 +313,19 @@ function shouldAppendCSS() {
307313 return hasMultipleFiles && hasOutputFile
308314}
309315
316+ function truncateDestinationFile ( ) {
317+ Promise . resolve ( )
318+ . then ( ( ) => {
319+ return fs . pathExists ( output )
320+ } )
321+ . then ( ( exists ) => {
322+ if ( exists ) {
323+ fs . truncate ( output , err => {
324+ if ( err ) return error ( 'Output Error : Cannot truncate output file.' )
325+ } )
326+ }
327+ } )
328+ . catch ( ex => {
329+ return error ( ex ) ;
330+ } )
331+ }
You can’t perform that action at this time.
0 commit comments