diff --git a/build.py b/build.py index 80441a6121..ed7b7a4b14 100755 --- a/build.py +++ b/build.py @@ -270,6 +270,7 @@ def examples_star_json(name, match): "exports": [], "src": [ "src/**/*.js", + "build/ol.ext/*.js", "examples/%(id)s.js" % match.groupdict()], "compile": { "js": [ diff --git a/config/examples-all.json b/config/examples-all.json index b3983b9673..f5b300e3ca 100644 --- a/config/examples-all.json +++ b/config/examples-all.json @@ -2,6 +2,7 @@ "exports": [], "src": [ "src/**/*.js", + "build/ol.ext/*.js", "build/examples/all.js" ], "compile": { diff --git a/package.json b/package.json index 5190d9467c..33c143b78f 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ ], "homepage": "http://openlayers.org/", "scripts": { - "install": "node tasks/parse-examples.js", + "install": "node tasks/install.js", "postinstall": "closure-util update", "start": "node tasks/serve.js", "test": "node tasks/test.js" diff --git a/tasks/build-ext.js b/tasks/build-ext.js index 70e4aaf2f7..a6cb6b3b92 100644 --- a/tasks/build-ext.js +++ b/tasks/build-ext.js @@ -71,9 +71,17 @@ function buildModules(modules, callback) { } -if (require.main === module) { +/** + * Build all external modules. + * @param {function(Error)} callback Called with any error. + */ +function main(callback) { var modules = getExternalModules(); - buildModules(modules, function(err) { + buildModules(modules, callback); +} + +if (require.main === module) { + main(function(err) { if (err) { process.stderr.write(err.message + '\n'); process.exit(1); @@ -82,3 +90,5 @@ if (require.main === module) { } }); } + +module.exports = main; diff --git a/tasks/build.js b/tasks/build.js index dd07d343cf..3f4fe2e2cf 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -127,7 +127,7 @@ function getDependencies(config, exports, callback) { }; } else { options = { - lib: ['src/**/*.js'], + lib: ['src/**/*.js', 'build/ol.ext/*.js'], cwd: root }; } diff --git a/tasks/install.js b/tasks/install.js new file mode 100644 index 0000000000..52cce80f8f --- /dev/null +++ b/tasks/install.js @@ -0,0 +1,17 @@ +var async = require('async'); + +var buildExt = require('./build-ext'); +var parseExamples = require('./parse-examples'); + +/** + * Parse examples and build external modules. + */ +async.waterfall([ + parseExamples, + buildExt +], function(err) { + if (err) { + process.stderr.write(err + '\n'); + process.exit(1); + } +}); diff --git a/tasks/parse-examples.js b/tasks/parse-examples.js index 09e86c1b64..8315da6716 100644 --- a/tasks/parse-examples.js +++ b/tasks/parse-examples.js @@ -137,14 +137,25 @@ function writeExampleList(exampleInfos, callback) { /** * List examples, parse them, and write example list. + * @param {function(Error)} callback Called with any error. */ -async.waterfall([ - listExamples, - parseExamples, - writeExampleList -], function(err) { - if (err) { - process.stderr.write(err + '\n'); - process.exit(1); - } -}); +function main(callback) { + async.waterfall([ + listExamples, + parseExamples, + writeExampleList + ], callback); +} + +if (require.main === module) { + main(function(err) { + if (err) { + process.stderr.write(err.message + '\n'); + process.exit(1); + } else { + process.exit(0); + } + }); +} + +module.exports = main; diff --git a/tasks/serve.js b/tasks/serve.js index 219ce69a5f..a7f792d51b 100644 --- a/tasks/serve.js +++ b/tasks/serve.js @@ -22,6 +22,7 @@ var createServer = exports.createServer = function(callback) { var manager = new closure.Manager({ lib: [ 'src/**/*.js', + 'build/ol.ext/*.js', 'test/spec/**/*.test.js' ], main: 'examples/*.js'