Pass around single config object

This commit is contained in:
Tim Schaub
2014-05-20 22:09:18 -06:00
committed by Andreas Hocevar
parent 3447f93bfe
commit 250f6901d3
2 changed files with 10 additions and 12 deletions
+1 -1
View File
@@ -186,7 +186,7 @@ function build(config, paths, callback) {
function main(config, callback) { function main(config, callback) {
async.waterfall([ async.waterfall([
assertValidConfig.bind(null, config), assertValidConfig.bind(null, config),
generateExports.bind(null, config.exports, config.namespace), generateExports.bind(null, config),
getDependencies.bind(null, config.src), getDependencies.bind(null, config.src),
build.bind(null, config) build.bind(null, config)
], callback); ], callback);
+9 -11
View File
@@ -11,13 +11,12 @@ var build = path.join(__dirname, '..', 'build');
/** /**
* Get a list of patterns from the config file. If configPath is provided * Get the configuration from the config file. If configPath is provided
* it is assumed to be a JSON file with an 'exports' member that is a list * it is assumed to be a JSON file with an 'exports' member that is a list
* of symbol names or patterns. * of symbol names or patterns.
* *
* @param {string} configPath Path to config file. * @param {string} configPath Path to config file.
* @param {function(Error, Array.<string>)} callback Called with the list of * @param {function(Error, Object)} callback Called with config object.
* patterns.
*/ */
function getConfig(configPath, callback) { function getConfig(configPath, callback) {
if (configPath) { if (configPath) {
@@ -44,11 +43,11 @@ function getConfig(configPath, callback) {
namespace)); namespace));
return; return;
} }
callback(null, patterns, namespace); callback(null, obj);
}); });
} else { } else {
process.nextTick(function() { process.nextTick(function() {
callback(null, ['*'], undefined); callback(null, {exports: ['*']});
}); });
} }
} }
@@ -131,7 +130,7 @@ function formatSymbolExport(name, namespace) {
return 'goog.exportSymbol(\n' + return 'goog.exportSymbol(\n' +
' \'' + name + '\',\n' + ' \'' + name + '\',\n' +
' ' + name + ' ' + name +
(namespace ? ',\n ' + namespace : '') +');\n'; (namespace ? ',\n ' + namespace : '') + ');\n';
} }
@@ -182,19 +181,18 @@ function generateExports(symbols, namespace) {
/** /**
* Generate the exports code. * Generate the exports code.
* *
* @param {Array.<string>} patterns List of symbol names or patterns. * @param {Object} config Config object with exports and (optional) namespace.
* @param {string|undefined} namespace Target object for exported symbols.
* @param {function(Error, string)} callback Called with the exports code or any * @param {function(Error, string)} callback Called with the exports code or any
* error generating it. * error generating it.
*/ */
function main(patterns, namespace, callback) { function main(config, callback) {
async.waterfall([ async.waterfall([
getSymbols.bind(null, patterns), getSymbols.bind(null, config.exports),
filterSymbols, filterSymbols,
function(symbols, done) { function(symbols, done) {
var code, err; var code, err;
try { try {
code = generateExports(symbols, namespace); code = generateExports(symbols, config.namespace);
} catch (e) { } catch (e) {
err = e; err = e;
} }