Skip to content

Commit 79a8b96

Browse files
author
Fatme
authored
Merge pull request #74 from NativeScript/fatme/compilation-error
Don't stop livesync process when sass compilation error occurs
2 parents 52b2bb2 + fa75397 commit 79a8b96

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/lib/converter.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ function createWatcher(data) {
4444

4545
watcher = choki.watch(['**/*.scss', '**/*.sass'], watcherOptions)
4646
.on('all', (event, filePath) => {
47-
watchPromisesChain = watchPromisesChain.then(() => spawnNodeSass(data));
47+
watchPromisesChain = watchPromisesChain
48+
.then(() => spawnNodeSass(data))
49+
.catch(err => {
50+
if (!err.stopExecution && err.errorAsWarning) {
51+
data.logger.warn(err.message);
52+
} else {
53+
throw err;
54+
}
55+
});
4856
});
4957
}
5058

@@ -110,6 +118,8 @@ function spawnNodeSass(data) {
110118
logger.info(err.message);
111119
if (!isResolved) {
112120
isResolved = true;
121+
err.errorAsWarning = true;
122+
err.stopExecution = false;
113123
reject(err);
114124
}
115125
});
@@ -122,7 +132,10 @@ function spawnNodeSass(data) {
122132
if (code === 0) {
123133
resolve();
124134
} else {
125-
reject(new Error('SASS compiler failed with exit code ' + code));
135+
var error = new Error('SASS compiler failed with exit code ' + code);
136+
error.errorAsWarning = true;
137+
error.stopExecution = false;
138+
reject(error);
126139
}
127140
}
128141
});

0 commit comments

Comments
 (0)