@@ -6,16 +6,17 @@ var fs = require('fs');
6
6
var path = require ( 'path' ) ;
7
7
var choki = require ( 'chokidar' ) ;
8
8
var watcher = null ;
9
+ var watchPromisesChain = Promise . resolve ( ) ;
9
10
10
11
function convert ( logger , projectDir , appDir , options ) {
11
12
options = options || { } ;
12
13
var sassPath = getSassPath ( ) ;
13
14
var data = {
14
- sassPath : sassPath ,
15
- projectDir : projectDir ,
16
- appDir : appDir ,
17
- logger : logger ,
18
- options : options
15
+ sassPath,
16
+ projectDir,
17
+ appDir,
18
+ logger,
19
+ options
19
20
} ;
20
21
21
22
if ( options . watch ) {
@@ -36,14 +37,14 @@ function createWatcher(data) {
36
37
cwd : appDir ,
37
38
awaitWriteFinish : {
38
39
pollInterval : 100 ,
39
- stabilityThreshold : 500
40
+ stabilityThreshold : 300
40
41
} ,
41
42
ignored : [ '**/.*' , '.*' ] // hidden files
42
43
} ;
43
44
44
45
watcher = choki . watch ( [ '**/*.scss' , '**/*.sass' ] , watcherOptions )
45
46
. on ( 'all' , ( event , filePath ) => {
46
- spawnNodeSass ( data ) ;
47
+ watchPromisesChain = watchPromisesChain . then ( ( ) => spawnNodeSass ( data ) ) ;
47
48
} ) ;
48
49
}
49
50
@@ -54,7 +55,7 @@ function getSassPath() {
54
55
logger . info ( 'Found peer node-sass' ) ;
55
56
} catch ( err ) { }
56
57
} else {
57
- throw Error ( 'node-sass installation local to project was not found. Install by executing `npm install node-sass`.' ) ;
58
+ throw new Error ( 'node-sass installation local to project was not found. Install by executing `npm install node-sass`.' ) ;
58
59
}
59
60
60
61
return sassPath ;
@@ -87,7 +88,6 @@ function spawnNodeSass(data) {
87
88
var currentSassProcess = spawn ( process . execPath , nodeArgs , { env : env } ) ;
88
89
89
90
var isResolved = false ;
90
- var watchResolveTimeout ;
91
91
92
92
currentSassProcess . stdout . on ( 'data' , function ( data ) {
93
93
var stringData = data . toString ( ) ;
@@ -124,15 +124,9 @@ function spawnNodeSass(data) {
124
124
if ( code === 0 ) {
125
125
resolve ( ) ;
126
126
} else {
127
- reject ( Error ( 'SASS compiler failed with exit code ' + code ) ) ;
127
+ reject ( new Error ( 'SASS compiler failed with exit code ' + code ) ) ;
128
128
}
129
129
}
130
130
} ) ;
131
-
132
- // SASS does not recompile on watch, so directly resolve.
133
- if ( options . watch && ! isResolved ) {
134
- isResolved = true ;
135
- resolve ( ) ;
136
- }
137
131
} ) ;
138
132
}
0 commit comments