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.
This commit is contained in:
+20
-35
@@ -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.
|
* Generate a build of the library.
|
||||||
* @param {Object} config Build configuration object. Must have an "exports"
|
* @param {Object} config Build configuration object. Must have an "exports"
|
||||||
@@ -199,40 +216,8 @@ function main(config, callback) {
|
|||||||
assertValidConfig.bind(null, config),
|
assertValidConfig.bind(null, config),
|
||||||
generateExports.bind(null, config),
|
generateExports.bind(null, config),
|
||||||
getDependencies.bind(null, config),
|
getDependencies.bind(null, config),
|
||||||
build.bind(null, config)
|
build.bind(null, config),
|
||||||
], callback);
|
addHeader
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)
|
|
||||||
], callback);
|
], callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +257,7 @@ if (require.main === module) {
|
|||||||
async.waterfall([
|
async.waterfall([
|
||||||
readConfig.bind(null, options.config),
|
readConfig.bind(null, options.config),
|
||||||
main,
|
main,
|
||||||
writeOutputfile
|
fse.outputFile.bind(fse, options.output)
|
||||||
], function(err) {
|
], function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error(err.message);
|
log.error(err.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user