Skip to content

Commit

Permalink
Rename reload mode to watch mode to match conventions established by …
Browse files Browse the repository at this point in the history
…supervisor, nodemon, mocha, etc.
  • Loading branch information
jaredhanson committed Aug 18, 2012
1 parent 8384c91 commit 5c2355f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bin/lcm.js
Expand Up @@ -17,7 +17,7 @@ program.command('server')
.option('-p, --port [port]', 'listen on specified port (default: 3000)', parseInt)
.option('-e, --env [environment]', 'run in specified environment (default: development)')
.option('-A, --app [directory]', 'load app at specified directory (default: `pwd`)')
.option('-R, --reload', 'enable automatic reloading when code changes')
.option('-w, --watch', 'watch for code changes and reload')
.option('--use-nodemon', 'use nodemon for automatic reloading (default: supervisor)')
.option('--debug [port]', 'enable V8 debugger on specified port (default: 5858)', parseInt)
.option('--debug-brk [port]', 'enable V8 debugger on specified port and break immediately (default: 5858)', parseInt)
Expand Down
18 changes: 5 additions & 13 deletions lib/locomotive/cli/server.js
Expand Up @@ -41,22 +41,14 @@ exports = module.exports = function server(dir, address, port, env, options) {
return;
}

if (options.reload) {
if (options.watch) {
if (options.useNodemon) {
// As of nodemon@0.6.14, there is an issue with passing the full path of a
// script to nodemon, which causes the spawned command to fail. See here
// for more discussion:
// https://github.com/remy/nodemon/issues/78
//
// I've submitted a pull request to fix this issue, which will hopefully
// find its way into a stable release.
// https://github.com/remy/nodemon/pull/81
var command = 'nodemon';
var args = [ '-w', dir,
path.join(__dirname, 'server/reload.js'),
path.join(__dirname, 'server/watch.js'),
dir, address, port, env ];

debug('respawning in reload mode (%s %s)', command, args.join(' '));
debug('respawning in watch mode (%s %s)', command, args.join(' '));

var proc = spawn(command, args);
proc.stdout.pipe(process.stdout);
Expand All @@ -75,10 +67,10 @@ exports = module.exports = function server(dir, address, port, env, options) {
// supervisor@0.3.0
var command = 'supervisor';
var args = [ '-w', dir, '--no-restart-on', 'error',
'--', path.join(__dirname, 'server/reload.js'),
'--', path.join(__dirname, 'server/watch.js'),
dir, address, port, env ];

debug('respawning in reload mode (%s %s)', command, args.join(' '));
debug('respawning in watch mode (%s %s)', command, args.join(' '));

var proc = spawn(command, args);
proc.stdout.pipe(process.stdout);
Expand Down
@@ -1,7 +1,7 @@
/**
* server/reload.js
* server/watch.js
*
* This is a shim script used by Locomotive when respawning in reload mode.
* This is a shim script used by Locomotive when respawning in watch mode.
*/

// process.argv[0] -> nodemon
Expand Down

0 comments on commit 5c2355f

Please sign in to comment.