]> arthur.barton.de Git - atom-ax-pipe.git/blobdiff - lib/pipe.coffee
cd to atom.project.path before executing commands. Resolve #1.
[atom-ax-pipe.git] / lib / pipe.coffee
index ec25ab594b2d63b307ff4aa46424f9277c7c833d..3a455eea73b5fcfd63a447972e5859077a8db463 100644 (file)
@@ -2,6 +2,8 @@
 {spawn} = require 'child_process'
 CommandView = require './command-view'
 
+history = []
+
 module.exports =
   activate: ->
     atom.workspaceView.command 'pipe:run', => @run()
@@ -11,15 +13,20 @@ module.exports =
     view = atom.workspaceView.getActiveView()
     return if not editor?
 
-    new CommandView (commandString) ->
+    new CommandView history, (commandString) ->
       if not commandString
         view.focus()
         return
 
+      history.push commandString
+      if history.length > 300
+        history.shift()
+
       range = editor.getSelectedBufferRange()
       stdout = ''
       stderr = ''
 
+      commandString = "cd #{atom.project.path} && #{commandString}"
       proc = spawn process.env.SHELL, ["-l", "-c", commandString]
 
       proc.stdout.on 'data', (text) ->