Skip to content

Instantly share code, notes, and snippets.

@joakimk
Last active April 5, 2018 13:10
Show Gist options
  • Save joakimk/5e5fb68bb33ac93f378440ea91ae5b22 to your computer and use it in GitHub Desktop.
Save joakimk/5e5fb68bb33ac93f378440ea91ae5b22 to your computer and use it in GitHub Desktop.
Running tests in tmux from Atom
# Atom -> Init Script...
child = require "child_process"
runTestInTmux = (focus) ->
editor = atom.workspace.getActiveTextEditor()
editor.save()
fullPath = editor.getPath()
projectPath = atom.project.getDirectories()[0].getPath() + "/"
relativePath = fullPath.split(projectPath)[1]
if focus
line = editor.getLastCursor().getBufferPosition().row
relativePath = relativePath + ":" + line
child.spawnSync("tmux", ["send-keys", "-l", "script/test " + relativePath + "\n"])
atom.commands.add "atom-text-editor", "custom:save-and-run-test-at-current-line", ->
runTestInTmux(true)
atom.commands.add "atom-text-editor", "custom:save-and-run-test", ->
runTestInTmux(false)
# Atom -> Keymap...
'atom-text-editor.vim-mode-plus:not(.insert-mode)':
'm': 'custom:save-and-run-test-at-current-line'
'M': 'custom:save-and-run-test'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment