Skip to content

Commit 57ae2d9

Browse files
committed
Fix PR comments
1 parent 55981a8 commit 57ae2d9

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

src/lib/converter.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ var fs = require('fs');
66
var path = require('path');
77
var choki = require('chokidar');
88
var watcher = null;
9+
var watchPromisesChain = Promise.resolve();
910

1011
function convert(logger, projectDir, appDir, options) {
1112
options = options || {};
1213
var sassPath = getSassPath();
1314
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
1920
};
2021

2122
if (options.watch) {
@@ -36,14 +37,14 @@ function createWatcher(data) {
3637
cwd: appDir,
3738
awaitWriteFinish: {
3839
pollInterval: 100,
39-
stabilityThreshold: 500
40+
stabilityThreshold: 300
4041
},
4142
ignored: ['**/.*', '.*'] // hidden files
4243
};
4344

4445
watcher = choki.watch(['**/*.scss', '**/*.sass'], watcherOptions)
4546
.on('all', (event, filePath) => {
46-
spawnNodeSass(data);
47+
watchPromisesChain = watchPromisesChain.then(() => spawnNodeSass(data));
4748
});
4849
}
4950

@@ -54,7 +55,7 @@ function getSassPath() {
5455
logger.info('Found peer node-sass');
5556
} catch (err) { }
5657
} 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`.');
5859
}
5960

6061
return sassPath;
@@ -87,7 +88,6 @@ function spawnNodeSass(data) {
8788
var currentSassProcess = spawn(process.execPath, nodeArgs, { env: env });
8889

8990
var isResolved = false;
90-
var watchResolveTimeout;
9191

9292
currentSassProcess.stdout.on('data', function (data) {
9393
var stringData = data.toString();
@@ -124,15 +124,9 @@ function spawnNodeSass(data) {
124124
if (code === 0) {
125125
resolve();
126126
} else {
127-
reject(Error('SASS compiler failed with exit code ' + code));
127+
reject(new Error('SASS compiler failed with exit code ' + code));
128128
}
129129
}
130130
});
131-
132-
// SASS does not recompile on watch, so directly resolve.
133-
if (options.watch && !isResolved) {
134-
isResolved = true;
135-
resolve();
136-
}
137131
});
138132
}

0 commit comments

Comments
 (0)