Skip to content

Commit b709f6b

Browse files
author
Monte Goulding
committed
Fix for issue #10
This commit resolves issue #10 by silently failing if the LiveCode Server process can not be spawned. In the process the dependency on atom-linter was factored out as it was necessary to re-implement helper.exec(). Rather than reject the promise as is the normal procedure in the event of an error here I have chosen to resolve with an empty output because it means you can fix the LiveCode Server process name and it will start linting in the same session.
1 parent a92b4ed commit b709f6b

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

lib/main.coffee

Lines changed: 18 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:
@@ -29,7 +29,6 @@ module.exports =
2929
@subscriptions.dispose()
3030

3131
provideLinter: ->
32-
helpers = require('atom-linter')
3332
provider =
3433
grammarScopes: ['source.livecodescript', 'source.iRev']
3534
scope: 'file'
@@ -45,7 +44,7 @@ module.exports =
4544
explicitVariables = '-explicitVariables=' + @explicitVars
4645
parameters.push(explicitVariables)
4746
text = textEditor.getText()
48-
return helpers.exec(command, parameters, {stdin: text}).then (output) ->
47+
return @exec(command, parameters, {stdin: text}).then (output) ->
4948
regex = /(\d+),(\d+),(.*)/g
5049
messages = []
5150
while((match = regex.exec(output)) isnt null)
@@ -59,3 +58,19 @@ module.exports =
5958
]
6059
text: match[3]
6160
return messages
61+
62+
exec: (command, args = [], options = {}) ->
63+
return new Promise (resolve, reject) ->
64+
data = stdout: [], stderr: []
65+
stdout = (output) -> data.stdout.push(output.toString())
66+
stderr = (output) -> data.stderr.push(output.toString())
67+
exit = ->
68+
resolve(data.stdout.join(''))
69+
handleError = (errorObject) ->
70+
errorObject.handle()
71+
resolve('')
72+
spawnedProcess = new BufferedProcess({command, args, options, stdout, stderr, exit})
73+
spawnedProcess.onWillThrowError(handleError)
74+
if options.stdin
75+
spawnedProcess.process.stdin.write(options.stdin.toString())
76+
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on mouseUp
1313
tab & tab & "symbols:" & cr & \
1414
tab & tab & tab & "builtins:" & cr & \
1515
tab & tab & tab & tab & "suggestions: [" into theSnippets
16-
16+
1717
# functions
1818
set the folder to specialFolderPath("home") & "/livecode/docs/dictionary/function"
1919
repeat for each line theFile in the files

0 commit comments

Comments
 (0)