From c3bddffecb8115727ff529e971ac8a20f7ede152 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 25 Jul 2014 12:50:58 -0600 Subject: [PATCH] Unconditionally add version info to the build header This reworks the changes in #2442 so we always include the version info, regardless of whether the module is run as main or not. This also addresses a few lint related issues. --- tasks/build.js | 55 ++++++++++++++++++-------------------------------- 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/tasks/build.js b/tasks/build.js index f57d91ad25..25b59ec053 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -187,6 +187,23 @@ function build(config, paths, callback) { } +/** + * Adds a file header with the most recent Git tag. + * @param {string} compiledSource The compiled library. + * @param {function(Error, string)} callback Called with the output + * ready to be written into a file, or any error. + */ +function addHeader(compiledSource, callback) { + exec('git describe --tags', function(error, stdout, stderr) { + var header = '// OpenLayers 3. See http://ol3.js.org/\n'; + if (stdout !== '') { + header += '// Version: ' + stdout + '\n'; + } + callback(null, header + compiledSource); + }); +} + + /** * Generate a build of the library. * @param {Object} config Build configuration object. Must have an "exports" @@ -199,40 +216,8 @@ function main(config, callback) { assertValidConfig.bind(null, config), generateExports.bind(null, config), getDependencies.bind(null, config), - build.bind(null, config) - ], callback); -} - - -/** - * Adds a file header with the most recent Git tag. - * @param {String} compiledSource The compiled library. - * @param {function(Error, sourcesWithHeader)} callback Called with the output - * ready to be written into a file, or any error. - */ -function addFileHeader(compiledSource, callback) { - exec('git describe --tags', function (error, stdout, stderr) { - var version = '\n'; - if (stdout !== '') { - version = stdout; - } - var fileHeader = - '// OpenLayers 3. See http://ol3.js.org/\n' + - '// Version: ' + version; - callback(null, fileHeader + compiledSource); - }); -}; - - -/** - * Write the compiled library to a file. - * @param {String} compiledSource The compiled library. - * @param {function(Error)} callback Called with an error if any. - */ -function writeOutputfile(compiledSource, callback) { - async.waterfall([ - addFileHeader.bind(null, compiledSource), - fse.outputFile.bind(fse, options.output) + build.bind(null, config), + addHeader ], callback); } @@ -272,7 +257,7 @@ if (require.main === module) { async.waterfall([ readConfig.bind(null, options.config), main, - writeOutputfile + fse.outputFile.bind(fse, options.output) ], function(err) { if (err) { log.error(err.message);