Accept a src config, add docs

This commit is contained in:
Tim Schaub
2014-04-11 15:42:47 -06:00
parent a28db38eef
commit 758eed357e
2 changed files with 27 additions and 10 deletions

View File

@@ -30,6 +30,10 @@ function assertValidConfig(config, callback) {
callback(new Error('Config missing "compile" object'));
return;
}
if (config.src && !Array.isArray(config.src)) {
callback(new Error('Config "src" must be an array'));
return;
}
callback(null);
});
}
@@ -63,12 +67,15 @@ function readConfig(configPath, callback) {
/**
* Get the list of sources sorted in dependency order.
* @param {Array.<string>} src List of paths or patterns to source files. By
* default, all .js files in the src directory are included.
* @param {function(Error, Array.<string>)} callback Called with a list of paths
* or any error.
*/
function getDependencies(callback) {
function getDependencies(src, callback) {
log.info('ol', 'Parsing dependencies');
closure.getDependencies({lib: ['src/**/*.js']}, function(err, paths) {
src = src || ['src/**/*.js'];
closure.getDependencies({lib: src}, function(err, paths) {
if (err) {
callback(err);
return;
@@ -88,7 +95,7 @@ function getDependencies(callback) {
*/
function build(options, paths, callback) {
log.info('ol', 'Compiling ' + paths.length + ' sources');
options.js = paths;
options.js = paths.concat(options.js || []);
closure.compile(options, callback);
}
@@ -104,7 +111,7 @@ function main(config, callback) {
async.waterfall([
assertValidConfig.bind(null, config),
generateExports.bind(null, config.exports),
getDependencies,
getDependencies.bind(null, config.src),
build.bind(null, config.compile)
], callback);
}