Skip to content

Commit c62bb39

Browse files
committed
Merge pull request #11 from montegoulding/bugfix/catch_execution_error
Fix for issue #10
2 parents a92b4ed + 047882f commit c62bb39

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed

lib/main.coffee

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{CompositeDisposable} = require 'atom'
1+
{BufferedProcess, CompositeDisposable} = require 'atom'
22

33
module.exports =
44
config:
@@ -24,12 +24,12 @@ module.exports =
2424
@explicitVars = explicitVars
2525
path = require 'path'
2626
@linterPath = path.join(__dirname, '..', 'tools', 'Linter.lc')
27+
@notified = false
2728

2829
deactivate: ->
2930
@subscriptions.dispose()
3031

3132
provideLinter: ->
32-
helpers = require('atom-linter')
3333
provider =
3434
grammarScopes: ['source.livecodescript', 'source.iRev']
3535
scope: 'file'
@@ -45,7 +45,7 @@ module.exports =
4545
explicitVariables = '-explicitVariables=' + @explicitVars
4646
parameters.push(explicitVariables)
4747
text = textEditor.getText()
48-
return helpers.exec(command, parameters, {stdin: text}).then (output) ->
48+
return @exec(command, parameters, {stdin: text}).then (output) ->
4949
regex = /(\d+),(\d+),(.*)/g
5050
messages = []
5151
while((match = regex.exec(output)) isnt null)
@@ -59,3 +59,28 @@ module.exports =
5959
]
6060
text: match[3]
6161
return messages
62+
63+
exec: (command, args = [], options = {}) ->
64+
return new Promise (resolve, reject) ->
65+
data = stdout: [], stderr: []
66+
stdout = (output) -> data.stdout.push(output.toString())
67+
stderr = (output) -> data.stderr.push(output.toString())
68+
exit = ->
69+
resolve(data.stdout.join(''))
70+
handleError = (errorObject) ->
71+
errorObject.handle()
72+
if !@notified
73+
atom.notifications.addWarning(
74+
'Please check you have LiveCode Server installed correctly',
75+
{
76+
detail: 'LiveCode Server is required for linting your files\n' +
77+
'edit the location in the package settings'
78+
}
79+
)
80+
@notified = true
81+
resolve('')
82+
spawnedProcess = new BufferedProcess({command, args, options, stdout, stderr, exit})
83+
spawnedProcess.onWillThrowError(handleError)
84+
if options.stdin
85+
spawnedProcess.process.stdin.write(options.stdin.toString())
86+
spawnedProcess.process.stdin.end() # We have to end it or the programs will keep waiting forever

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
"atom": "*"
99
},
1010
"main": "./lib/main",
11-
"dependencies": {
12-
"atom-linter": "^3.0.0"
13-
},
1411
"providedServices": {
1512
"linter": {
1613
"versions": {

tools/GenerateSnippets.livecodescript

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ on mouseUp
1313
tab & tab & "symbols:" & cr & \
1414
tab & tab & tab & "builtins:" & cr & \
1515
tab & tab & tab & tab & "suggestions: [" into theSnippets
16-
16+
17+
1718
# functions
1819
set the folder to specialFolderPath("home") & "/livecode/docs/dictionary/function"
1920
repeat for each line theFile in the files

0 commit comments

Comments
 (0)