Remove goog.asserts.*

This pull requests replaces type check hint assertions with type casts,
library sanity check assertions with conditional console.assert statements
in debug mode, and runtime sanity checks with assertions that throw an
ol.AssertionError with an error code for lookup outside the library.
This commit is contained in:
Andreas Hocevar
2016-07-19 16:39:58 +02:00
parent f50f1f401c
commit 6f5ed17fc5
158 changed files with 1488 additions and 1629 deletions

View File

@@ -29,6 +29,8 @@ var umdWrapper = ';(function (root, factory) {\n' +
' return OPENLAYERS.ol;\n' +
'}));\n';
var version;
/**
* Apply defaults and assert that a provided config object is valid.
@@ -61,6 +63,12 @@ function assertValidConfig(config, callback) {
config.namespace = 'OPENLAYERS';
if (config.compile) {
config.compile.output_wrapper = umdWrapper;
if (version) {
if (!config.compile.define) {
config.compile.define = [];
}
config.compile.define.push('ol.VERSION=\'' + version + '\'');
}
}
}
callback(null);
@@ -179,6 +187,7 @@ function concatenate(paths, callback) {
'var goog = this.goog = {};\n' +
'this.CLOSURE_NO_DEPS = true;\n' +
results.join('\n') +
'ol.VERSION = \'' + version + '\';\n' +
'OPENLAYERS.ol = ol;\n' +
parts[1];
callback(null, src);
@@ -213,6 +222,19 @@ function build(config, paths, callback) {
}
/**
* Gets the version from the Git tag.
* @param {function(Error, string)} callback Called with the output
* ready to be written into a file, or any error.
*/
function getVersion(callback) {
exec('git describe --tags', function(error, stdout, stderr) {
version = stdout.trim();
callback(null);
});
}
/**
* Adds a file header with the most recent Git tag.
* @param {string} compiledSource The compiled library.
@@ -220,15 +242,13 @@ function build(config, paths, callback) {
* 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://openlayers.org/\n';
header += '// License: https://raw.githubusercontent.com/openlayers/' +
'ol3/master/LICENSE.md\n';
if (stdout !== '') {
header += '// Version: ' + stdout + '\n';
}
callback(null, header + compiledSource);
});
var header = '// OpenLayers 3. See http://openlayers.org/\n';
header += '// License: https://raw.githubusercontent.com/openlayers/' +
'ol3/master/LICENSE.md\n';
if (version !== '') {
header += '// Version: ' + version + '\n';
}
callback(null, header + compiledSource);
}
@@ -241,6 +261,7 @@ function addHeader(compiledSource, callback) {
*/
function main(config, callback) {
async.waterfall([
getVersion,
assertValidConfig.bind(null, config),
generateExports.bind(null, config),
getDependencies.bind(null, config),