Closed
Description
Pull out our option handling into a sub-module that can be used by some of the other tooling that we are building. It would also include some utility methods for determining if a given file was a test or helper or source, etc:
var Config = require('ava/config');
var config = new Config({
// defaults
args: process.argv.slice(2),
cwd: process.cwd(),
pkg: pkgConf.sync('ava', {cwd})
});
// config.options would simply be our merged options
config.options.serial // boolean
config.options.watch // boolean
// convenience methods
config.isTest('/some/path');
config.isSource('/some/path');
config.isHelper('/some/path');
// Maybe move some of the file watching here? I don't know that anything needs this yet.
var watcher = config.watchChanges();
// events are not immediate (like with chokidar), but debounced like we already do in watcher.
watcher.on('source-changed', filename => {});
watcher.on('sources-changed', filenameArray => {});
watcher.on('test-changed', filename => {});
watcher.on('helper-changed', filename => {});
watcher.on('files-changed', obj => {
obj.tests // a array
obj.sources // a array
obj.helpers // a array
});