1- {CompositeDisposable } = require ' atom'
1+ {BufferedProcess , CompositeDisposable } = require ' atom'
22
33module .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
0 commit comments