From afc4123adcb65f660d6f3eba69d44ef75b561970 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Wed, 28 May 2014 10:52:00 -0400 Subject: [PATCH] add --start option --- bin/tend | 4 +++- lib/index.js | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/tend b/bin/tend index b470ee9..07c23ce 100755 --- a/bin/tend +++ b/bin/tend @@ -7,13 +7,14 @@ var doc = [ 'Usage:', ' tend', ' tend (--help | --version)', - ' tend [--restart] [--ignoreHidden] [ ] []', + ' tend [--restart] [--start] [--ignoreHidden] [ ] []', '', 'Options:', ' -h --help Show this help text', ' -v --version Show tend version information', ' -r --restart If is still running when there is a change, stop and re-run it', ' -i --ignoreHidden Ignore changes to files which start with "."', + ' -s --start Run as soon as tend executes', ].join('\r\n'); var args = docopt.docopt(doc, { @@ -36,6 +37,7 @@ if (args[''] && args['']) { filter: args[''], ignoreHidden: args['--ignoreHidden'], restart: args['--restart'], + start: args['--start'], command: args[''], directory: args[''], } diff --git a/lib/index.js b/lib/index.js index 4bbe590..eeadc56 100644 --- a/lib/index.js +++ b/lib/index.js @@ -75,6 +75,10 @@ module.exports.tend = function(dir, rawCommand, options) { clearTimeout(timeout); timeout = setTimeout(startCommand, 300); }); + + if(options.start){ + startCommand(); + } }; module.exports.parseConfig = function() { @@ -85,6 +89,7 @@ module.exports.parseConfig = function() { filter: rawConfig.filter || '.', ignoreHidden: (rawConfig.ignoreHidden === undefined) ? false : rawConfig.ignoreHidden, restart: (rawConfig.restart === undefined) ? false : rawConfig.restart, + start: (rawConfig.start === undefined) ? false : rawConfig.start, }; for (var key in rawConfig) { @@ -103,6 +108,7 @@ module.exports.parseConfig = function() { filter: (section.filter === undefined) ? defaults.filter : section.filter, ignoreHidden: (section.ignoreHidden === undefined) ? defaults.ignoreHidden : section.ignoreHidden, restart: (section.restart === undefined) ? defaults.restart : section.restart, + start: (section.start === undefined) ? defaults.start : section.start, directory: section.directory, command: section.command };