|
|
|
@ -1,12 +1,13 @@ |
|
|
|
var colors = require('colors'); |
|
|
|
var path = require('path'); |
|
|
|
var parse = require('shell-quote').parse; |
|
|
|
var path = require('path'); |
|
|
|
var rc = require('rc'); |
|
|
|
var spawn = require('child_process').spawn; |
|
|
|
var watch = require('watch'); |
|
|
|
|
|
|
|
module.exports.tend = function(dir, rawCommand, options) { |
|
|
|
options = options || {}; |
|
|
|
var pattern = options.pattern || '.'; |
|
|
|
var pattern = options.filter || '.'; |
|
|
|
var filter = new RegExp(pattern, 'i'); |
|
|
|
|
|
|
|
var ignoreHidden = options.ignoreHidden === true; |
|
|
|
@ -72,3 +73,40 @@ module.exports.tend = function(dir, rawCommand, options) { |
|
|
|
timeout = setTimeout(startCommand, 300); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
module.exports.parseConfig = function() { |
|
|
|
var config = {}; |
|
|
|
var rawConfig = rc('tend', {}, {}); |
|
|
|
|
|
|
|
var defaults = { |
|
|
|
filter: rawConfig.filter || '.', |
|
|
|
ignoreHidden: (rawConfig.ignoreHidden === undefined) ? false : rawConfig.ignoreHidden, |
|
|
|
restart: (rawConfig.restart === undefined) ? false : rawConfig.restart, |
|
|
|
}; |
|
|
|
|
|
|
|
for (var key in rawConfig) { |
|
|
|
if (!(rawConfig[key] instanceof Object)) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
var section = rawConfig[key]; |
|
|
|
if (!section.directory) { |
|
|
|
console.error('Section[' + key + '] missing "directory" setting'); |
|
|
|
continue; |
|
|
|
} else if (!section.command) { |
|
|
|
console.error('Section[' + key + '] missing "command" setting'); |
|
|
|
continue; |
|
|
|
} |
|
|
|
config[key] = { |
|
|
|
filter: (section.filter === undefined) ? defaults.filter : section.filter, |
|
|
|
ignoreHidden: (section.ignoreHidden === undefined) ? defaults.ignoreHidden : section.ignoreHidden, |
|
|
|
restart: (section.restart === undefined) ? defaults.restart : section.restart, |
|
|
|
directory: section.directory, |
|
|
|
command: section.command |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
if (!Object.keys(config).length) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return config; |
|
|
|
}; |