Write version in builds
This commit is contained in:
+1
-1
@@ -58,7 +58,7 @@
|
|||||||
"es5Strict"
|
"es5Strict"
|
||||||
],
|
],
|
||||||
"compilation_level": "ADVANCED",
|
"compilation_level": "ADVANCED",
|
||||||
"output_wrapper": "// OpenLayers 3. See http://ol3.js.org/\n(function(){%output%})();",
|
"output_wrapper": "(function(){%output%})();",
|
||||||
"use_types_for_optimization": true,
|
"use_types_for_optimization": true,
|
||||||
"manage_closure_dependencies": true
|
"manage_closure_dependencies": true
|
||||||
}
|
}
|
||||||
|
|||||||
+35
-1
@@ -9,6 +9,7 @@ var fse = require('fs-extra');
|
|||||||
var fs = require('graceful-fs');
|
var fs = require('graceful-fs');
|
||||||
var nomnom = require('nomnom');
|
var nomnom = require('nomnom');
|
||||||
var temp = require('temp').track();
|
var temp = require('temp').track();
|
||||||
|
var exec = require('child_process').exec;
|
||||||
|
|
||||||
var generateExports = require('./generate-exports');
|
var generateExports = require('./generate-exports');
|
||||||
|
|
||||||
@@ -203,6 +204,39 @@ function main(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)
|
||||||
|
], callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If running this module directly, read the config file and call the main
|
* If running this module directly, read the config file and call the main
|
||||||
* function.
|
* function.
|
||||||
@@ -238,7 +272,7 @@ if (require.main === module) {
|
|||||||
async.waterfall([
|
async.waterfall([
|
||||||
readConfig.bind(null, options.config),
|
readConfig.bind(null, options.config),
|
||||||
main,
|
main,
|
||||||
fse.outputFile.bind(fse, options.output)
|
writeOutputfile
|
||||||
], function(err) {
|
], function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.error(err.message);
|
log.error(err.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user