listen-spawn

Start a HTTP server which runs commands when pinged.

listen-spawn

Start a server to run commands when touched.

It was designed to allow for execution of semi-frequent commands but not on every save.

This is accomplished by being a generic HTTP server with the ability to write text editor specific plugins to ping the server.

Sublime Text 2 terminal

Install the module globally with: npm install -g listen-spawn

# Navigate to your working directory 
cd my_project
 
# Set up listen-spawn to run `npm test` 
listen-spawn -- npm test # Listening at http://localhost:3000/ [...] 
 
# In a separate process, curl the server to run `npm test` again 
curl http://localhost:3000/ # > my_project@0.1.0 test [...] 

I am still looking for a silent yet plugin-free solution. If really want a one-off plugin, please open a GitHub issue.

For the time being, the following shortcut invokes a curl request to http://localhost:3000/ when alt+x is pressed.

// Add the following to your "Key Bindings - User" inside the [] 
{ "keys": ["alt+x"], "command": "exec", "args": {"cmd": ["curl", "http://localhost:3000/"]} }

For the Windows users, please install MinGW (should be installed with msysgit) and add it to your PATH.

listen-spawn installs a CLI endpoint via npm. It is good practice to always use -- to separate options from command as this can lead to unintended parsing.

$ listen-spawn
Usage: listen-spawn [options] -- command [args...]
Starts server and invokes command with arguments whenever touched.
 
Options:
  --port  Port to start server on  [default: 3000]
$ listen-spawn -- mocha test/assert.js
20 Jun 04:17:58 - [listen-spawn] Listening at http://localhost:3000/
20 Jun 04:17:58 - [listen-spawn] Starting new process -- mocha test/assert.js
 
  ․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․․
 
  42 tests complete (16 ms)
 
20 Jun 04:17:58 - [listen-spawn] App exited cleanly
$ listen-spawn -- node example/launch.js
20 Jun 04:20:25 - [listen-spawn] Listening at http://localhost:3000/
20 Jun 04:20:25 - [listen-spawn] Starting new process -- node example/launch.js
Starting browser
[...]

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via grunt and test via npm test.

Copyright (c) 2013 Todd Wolfson

Licensed under the MIT license.