From 224e3a42a23edf0d11ede2c0ecabf80cc69b2b34 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 16 Oct 2016 16:06:37 +0200 Subject: [PATCH] Gulp: port the `all`, `extension` and `jsdoc` targets This requires the `run-sequence` dependency because Gulp does not have a way to run sequences of tasks inside a Gulp task. Gulp 4.0 will have support for this, but until that is released this is the recommended way to implement it. --- gulpfile.js | 32 ++++++++++++++++++++++++++++++++ make.js | 38 +++----------------------------------- package.json | 2 ++ 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 07cac6655..becbb87f2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,7 +20,9 @@ var fs = require('fs'); var gulp = require('gulp'); var gutil = require('gulp-util'); +var mkdirp = require('mkdirp'); var rimraf = require('rimraf'); +var runSequence = require('run-sequence'); var stream = require('stream'); var exec = require('child_process').exec; var spawn = require('child_process').spawn; @@ -28,6 +30,7 @@ var streamqueue = require('streamqueue'); var zip = require('gulp-zip'); var BUILD_DIR = 'build/'; +var JSDOC_DIR = 'jsdoc/'; var L10N_DIR = 'l10n/'; var TEST_DIR = 'test/'; @@ -339,6 +342,13 @@ gulp.task('default', function() { }); }); +gulp.task('extension', function (done) { + console.log(); + console.log('### Building extensions'); + + runSequence('locale', ['firefox', 'chromium'], done); +}); + gulp.task('buildnumber', function (done) { console.log(); console.log('### Getting extension build number'); @@ -421,6 +431,28 @@ gulp.task('bundle', ['buildnumber'], function () { return createBundle(DEFINES).pipe(gulp.dest(BUILD_DIR)); }); +gulp.task('jsdoc', function (done) { + console.log(); + console.log('### Generating documentation (JSDoc)'); + + var JSDOC_FILES = [ + 'src/doc_helper.js', + 'src/display/api.js', + 'src/display/global.js', + 'src/shared/util.js', + 'src/core/annotation.js' + ]; + + var directory = BUILD_DIR + JSDOC_DIR; + rimraf(directory, function () { + mkdirp(directory, function () { + var command = '"node_modules/.bin/jsdoc" -d ' + directory + ' ' + + JSDOC_FILES.join(' '); + exec(command, done); + }); + }); +}); + gulp.task('publish', ['generic'], function (done) { var version = JSON.parse( fs.readFileSync(BUILD_DIR + 'version.json').toString()).version; diff --git a/make.js b/make.js index c14eba0a4..e431b9ba0 100644 --- a/make.js +++ b/make.js @@ -79,13 +79,7 @@ function getCurrentVersion() { // make all // target.all = function() { - // Don't do anything by default - echo('Please specify a target. Available targets:'); - for (var t in target) { - if (t !== 'all') { - echo(' ' + t); - } - } + exit(exec('gulp default')); }; @@ -194,27 +188,7 @@ target.components = function() { }; target.jsdoc = function() { - echo(); - echo('### Generating jsdoc'); - - var JSDOC_FILES = [ - 'src/doc_helper.js', - 'src/display/api.js', - 'src/display/global.js', - 'src/shared/util.js', - 'src/core/annotation.js' - ]; - - if (test('-d', JSDOC_DIR)) { - rm('-rf', JSDOC_DIR); - } - - mkdir('-p',JSDOC_DIR); - - exec('"node_modules/.bin/jsdoc" -d "' + JSDOC_DIR + '" ' + - JSDOC_FILES.join(' ')); - - echo(); + exit(exec('gulp jsdoc')); }; // @@ -617,13 +591,7 @@ target.minified = function() { // make extension // target.extension = function() { - cd(ROOT_DIR); - echo(); - echo('### Building extensions'); - - target.locale(); - target.firefox(); - target.chromium(); + exit(exec('gulp extension')); }; target.buildnumber = function() { diff --git a/package.json b/package.json index 458713d52..2bf86aaf3 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,11 @@ "jasmine-core": "^2.4.1", "jsdoc": "^3.3.0-alpha9", "jshint": "~2.8.0", + "mkdirp": "^0.5.1", "node-ensure": "^0.0.0", "requirejs": "^2.1.22", "rimraf": "^2.4.1", + "run-sequence": "^1.2.2", "shelljs": "~0.4.0", "streamqueue": "^1.1.1", "typogr": "~0.6.5",