Stop using the deprecated gulp-util module

The `gulp-util` module is now deprecated and authors are asked to stop
using it (refer to https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5 for
more information).

PDF.js does not rely on it that much, fortunately, so it's relatively
easy for us to remove the dependency. This patch does that by making the
following changes:

- Require `gulp-zip` version 4.1.0 or higher since they already removed
  their `gulp-util` dependency in that version.
- Replace `gulp-util.log` with the `fancylog` module as recommended in
  the article above.
- Replace `gulp-util.File` with the `Vinyl` module as recommended in the
  article above.

The only change I had to make for Vinyl is removing the `base` and `cwd`
lines since they may not be empty strings anymore. This way we fall back
to the defaults Vinyl provides, which for us doesn't matter since we
move the file afterwards anyway. Moreover, I used `vfs` for `vinyl-fs`
in the `Gulpfile` to avoid confusion with `vinyl` (which is also how the
documentation names the variable).

This is all we can do on our side; the other modules that still use
`gulp-util` must be updated upstream.
This commit is contained in:
Tim van der Meij 2017-12-30 19:47:08 +01:00
parent 4cc0f8c721
commit d688b8ea31
No known key found for this signature in database
GPG Key ID: 8C3FD2925A5F2762
2 changed files with 15 additions and 15 deletions

View File

@ -18,9 +18,9 @@
'use strict';
var fancylog = require('fancy-log');
var fs = require('fs');
var gulp = require('gulp');
var gutil = require('gulp-util');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var transform = require('gulp-transform');
@ -36,7 +36,8 @@ var merge = require('merge-stream');
var zip = require('gulp-zip');
var webpack2 = require('webpack');
var webpackStream = require('webpack-stream');
var vinyl = require('vinyl-fs');
var Vinyl = require('vinyl');
var vfs = require('vinyl-fs');
var BUILD_DIR = 'build/';
var L10N_DIR = 'l10n/';
@ -108,9 +109,7 @@ function safeSpawnSync(command, parameters, options) {
function createStringSource(filename, content) {
var source = stream.Readable({ objectMode: true, });
source._read = function () {
this.push(new gutil.File({
cwd: '',
base: '',
this.push(new Vinyl({
path: filename,
contents: new Buffer(content),
}));
@ -1217,10 +1216,10 @@ gulp.task('gh-pages-prepare', ['web-pre'], function () {
rimraf.sync(GH_PAGES_DIR);
// 'vinyl' because web/viewer.html needs its BOM.
// 'vfs' because web/viewer.html needs its BOM.
return merge([
vinyl.src(GENERIC_DIR + '**/*', { base: GENERIC_DIR, stripBOM: false, })
.pipe(gulp.dest(GH_PAGES_DIR)),
vfs.src(GENERIC_DIR + '**/*', { base: GENERIC_DIR, stripBOM: false, })
.pipe(gulp.dest(GH_PAGES_DIR)),
gulp.src([FIREFOX_BUILD_DIR + '*.xpi',
FIREFOX_BUILD_DIR + '*.rdf'])
.pipe(gulp.dest(GH_PAGES_DIR + EXTENSION_SRC_DIR + 'firefox/')),
@ -1340,9 +1339,9 @@ gulp.task('dist-pre',
.pipe(gulp.dest('build/dist/')),
packageJsonSrc.pipe(gulp.dest(DIST_DIR)),
bowerJsonSrc.pipe(gulp.dest(DIST_DIR)),
vinyl.src('external/dist/**/*',
{ base: 'external/dist', stripBOM: false, })
.pipe(gulp.dest(DIST_DIR)),
vfs.src('external/dist/**/*',
{ base: 'external/dist', stripBOM: false, })
.pipe(gulp.dest(DIST_DIR)),
gulp.src(GENERIC_DIR + 'LICENSE')
.pipe(gulp.dest(DIST_DIR)),
gulp.src(GENERIC_DIR + 'web/cmaps/**/*',
@ -1461,10 +1460,10 @@ gulp.task('mozcentraldiff', ['mozcentral', 'mozcentralbaseline'],
});
gulp.task('externaltest', function () {
gutil.log('Running test-fixtures.js');
fancylog('Running test-fixtures.js');
safeSpawnSync('node', ['external/builder/test-fixtures.js'],
{ stdio: 'inherit', });
gutil.log('Running test-fixtures_esprima.js');
fancylog('Running test-fixtures_esprima.js');
safeSpawnSync('node', ['external/builder/test-fixtures_esprima.js'],
{ stdio: 'inherit', });
});

View File

@ -12,12 +12,12 @@
"eslint": "^4.10.0",
"eslint-plugin-mozilla": "^0.4.9",
"eslint-plugin-no-unsanitized": "^2.0.1",
"fancy-log": "^1.3.2",
"gulp": "^3.9.1",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.6.1",
"gulp-transform": "^3.0.5",
"gulp-util": "^3.0.8",
"gulp-zip": "^4.0.0",
"gulp-zip": "^4.1.0",
"jasmine": "^2.8.0",
"jasmine-core": "^2.8.0",
"jsdoc": "^3.5.5",
@ -31,6 +31,7 @@
"ttest": "^1.1.0",
"typogr": "^0.6.7",
"uglify-es": "^3.1.2",
"vinyl": "^2.1.0",
"vinyl-fs": "^2.4.4",
"webpack": "^3.6.0",
"webpack-stream": "^4.0.0",