Skip to content

Instantly share code, notes, and snippets.

@joakimk joakimk/init.coffee
Last active Apr 5, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.