Skip to content

Commit 1fdde65

Browse files
committed
Merge pull request #245 from parallaxinc/tokenize-before-scan
attempt to tokenize before scanning ports during a download attempt, still scanning on identify
2 parents 3e641e6 + 41204a1 commit 1fdde65

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

src/plugins/handlers.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,19 @@ function handlers(app, opts, done){
287287
workspace.updateContent(cm.getValue());
288288
}
289289

290-
function syntaxCheck() {
290+
function compile(){
291291
const { content } = workspace.getState();
292292
// TODO: it is a pain that compile requires `this`
293293
const result = app.compile({
294294
type: 'bs2',
295295
source: content
296296
});
297-
if(result.error){
298-
const err = result.error;
297+
298+
return result.error;
299+
}
300+
301+
function handleError(err){
302+
if(err){
299303
// leaving this in for better debugging of errors
300304
console.log(err);
301305

@@ -310,6 +314,11 @@ function handlers(app, opts, done){
310314
}
311315
}
312316

317+
function syntaxCheck(){
318+
const err = compile();
319+
handleError(err);
320+
}
321+
313322
function transmitInput(value){
314323
const { device } = store.getState();
315324
const { selected } = device;
@@ -446,16 +455,7 @@ function handlers(app, opts, done){
446455

447456
toast.show(`'${filename}' downloaded successfully`, successToastOpts);
448457
})
449-
.catch(function(err){
450-
// TODO: this is used twice, should be a util or something
451-
// leaving this in for better debugging of errors
452-
console.log(err);
453-
toast.show(err.message, errorToastOpts);
454-
455-
if(err && err.errorLength){
456-
highlighter(err.errorPosition, err.errorLength);
457-
}
458-
})
458+
.catch(handleError)
459459
.finally(function(){
460460
board.removeListener('progress', onProgress);
461461
resetDownloadProgress();
@@ -489,6 +489,16 @@ function handlers(app, opts, done){
489489
const { autoDownload } = device;
490490
const { content } = workspace.getState();
491491

492+
if(autoDownload){
493+
const err = compile();
494+
495+
if(err){
496+
handleError(err);
497+
hideOverlay();
498+
return;
499+
}
500+
}
501+
492502
const scanOpts = {
493503
reject: [
494504
/Bluetooth-Incoming-Port/,

0 commit comments

Comments
 (0)