Skip to content

Commit

Permalink
Prevent errors when running from command palette
Browse files Browse the repository at this point in the history
  • Loading branch information
jubianchi committed Nov 21, 2015
1 parent e5669bf commit 1f584b2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
2 changes: 2 additions & 0 deletions lib/panel.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class AtoumPanel

item = $(item).attr 'data-path'

return unless item

@runner.shouldRunFile(item) unless @runner.shouldRunDirectory(item)


Expand Down
36 changes: 21 additions & 15 deletions lib/runner.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,32 @@ class AtoumRunner extends Emitter
@stop()

shouldRunDirectory: (directory) ->
unless fs.statSync(directory).isDirectory()
@emit 'error', directory + 'is not a directory'
@didExit 255
try
unless fs.statSync(directory).isDirectory()
@emit 'error', directory + 'is not a directory\n'
@didExit 255

false
else
@target = directory
false
else
@target = directory

@start()
@start()
catch
@emit 'error', 'Unable to run directory\n'

shouldRunFile: (file) ->
if fs.statSync(file).isDirectory()
@emit 'error', file + 'is a directory'
@didExit 255
try
if fs.statSync(file).isDirectory()
@emit 'error', file + 'is a directory\n'
@didExit 255

false
else
@target = file
false
else
@target = file

@start()
@start()
catch
@emit 'error', 'Unable to run file\n'

start: ->
out = (data) => @emit 'output', data
Expand All @@ -45,7 +51,7 @@ class AtoumRunner extends Emitter
args = @configurator.getArguments @target

if not args
@emit 'error', 'Could not find atoum binary'
@emit 'error', 'Could not find atoum binary\n'
@didExit 255

false
Expand Down

0 comments on commit 1f584b2

Please sign in to comment.