Skip to content

Commit

Permalink
Merge pull request #9 from steffentchr/patch-1
Browse files Browse the repository at this point in the history
Allow `command` to be a function returning an array.
  • Loading branch information
mafintosh committed Jan 5, 2016
2 parents 7c3ce56 + 43846d6 commit 11ce6d3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ Monitor.prototype.start = function() {
var clock = 60000

var loop = function() {
var child = spawn(self.command[0], self.command.slice(1), {
var cmd = (typeof(self.command)=='function' ? self.command() : self.command)
var child = spawn(cmd[0], cmd.slice(1), {
cwd: self.cwd,
env: xtend(process.env, self.env),
uid: self.uid,
Expand Down Expand Up @@ -204,7 +205,7 @@ Monitor.prototype._stopped = function() {
}

var respawn = function(command, opts) {
if (!Array.isArray(command)) return respawn(command.command, command)
if (typeof(command) != 'function' && !Array.isArray(command)) return respawn(command.command, command)
return new Monitor(command, opts || {})
}

Expand Down

0 comments on commit 11ce6d3

Please sign in to comment.