From 92434b1eb4998ab2f742a4644909e8dde01f557f Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 3 Jun 2021 15:44:17 +0200 Subject: [PATCH 1/3] Replace anonymous functions in `gulpfile.js` with named functions (issue 10362) This replaces all of the `Starting ''...` lines in the output, when running various `gulp` tasks, with more meaningful function names. --- gulpfile.js | 177 +++++++++++++++++++++++++++++----------------------- 1 file changed, 99 insertions(+), 78 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index ed35449f2..fe1e09789 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -829,14 +829,14 @@ gulp.task( gulp.series( "buildnumber", "locale", - function scripting() { + function scriptingGeneric() { const defines = builder.merge(DEFINES, { GENERIC: true }); return merge([ buildDefaultPreferences(defines, "generic/"), createTemporaryScriptingBundle(defines), ]); }, - function () { + function createGeneric() { console.log(); console.log("### Creating generic viewer"); const defines = builder.merge(DEFINES, { GENERIC: true }); @@ -853,7 +853,7 @@ gulp.task( gulp.series( "buildnumber", "locale", - function scripting() { + function scriptingGenericLegacy() { const defines = builder.merge(DEFINES, { GENERIC: true, SKIP_BABEL: false, @@ -863,7 +863,7 @@ gulp.task( createTemporaryScriptingBundle(defines), ]); }, - function () { + function createGenericLegacy() { console.log(); console.log("### Creating generic (legacy) viewer"); const defines = builder.merge(DEFINES, { @@ -896,7 +896,7 @@ function buildComponents(defines, dir) { gulp.task( "components", - gulp.series("buildnumber", function () { + gulp.series("buildnumber", function createComponents() { console.log(); console.log("### Creating generic components"); const defines = builder.merge(DEFINES, { COMPONENTS: true, GENERIC: true }); @@ -907,7 +907,7 @@ gulp.task( gulp.task( "components-legacy", - gulp.series("buildnumber", function () { + gulp.series("buildnumber", function createComponentsLegacy() { console.log(); console.log("### Creating generic (legacy) components"); const defines = builder.merge(DEFINES, { @@ -922,7 +922,7 @@ gulp.task( gulp.task( "image_decoders", - gulp.series("buildnumber", function () { + gulp.series("buildnumber", function createImageDecoders() { console.log(); console.log("### Creating image decoders"); const defines = builder.merge(DEFINES, { @@ -938,7 +938,7 @@ gulp.task( gulp.task( "image_decoders-legacy", - gulp.series("buildnumber", function () { + gulp.series("buildnumber", function createImageDecodersLegacy() { console.log(); console.log("### Creating (legacy) image decoders"); const defines = builder.merge(DEFINES, { @@ -996,14 +996,14 @@ gulp.task( gulp.series( "buildnumber", "locale", - function scripting() { + function scriptingMinified() { const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true }); return merge([ buildDefaultPreferences(defines, "minified/"), createTemporaryScriptingBundle(defines), ]); }, - function () { + function createMinified() { console.log(); console.log("### Creating minified viewer"); const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true }); @@ -1018,7 +1018,7 @@ gulp.task( gulp.series( "buildnumber", "locale", - function scripting() { + function scriptingMinifiedLegacy() { const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true, @@ -1029,7 +1029,7 @@ gulp.task( createTemporaryScriptingBundle(defines), ]); }, - function () { + function createMinifiedLegacy() { console.log(); console.log("### Creating minified (legacy) viewer"); const defines = builder.merge(DEFINES, { @@ -1116,7 +1116,7 @@ async function parseMinified(dir) { gulp.task( "minified", - gulp.series("minified-pre", async function (done) { + gulp.series("minified-pre", async function minifiedPost(done) { await parseMinified(MINIFIED_DIR); done(); }) @@ -1124,7 +1124,7 @@ gulp.task( gulp.task( "minified-legacy", - gulp.series("minified-legacy-pre", async function (done) { + gulp.series("minified-legacy-pre", async function minifiedLegacyPost(done) { await parseMinified(MINIFIED_LEGACY_DIR); done(); }) @@ -1166,11 +1166,11 @@ gulp.task( "mozcentral-pre", gulp.series( "buildnumber", - function scripting() { + function scriptingMozcentral() { const defines = builder.merge(DEFINES, { MOZCENTRAL: true }); return buildDefaultPreferences(defines, "mozcentral/"); }, - function () { + function createMozcentral() { console.log(); console.log("### Building mozilla-central extension"); const defines = builder.merge(DEFINES, { MOZCENTRAL: true }); @@ -1260,7 +1260,7 @@ gulp.task( gulp.series( "buildnumber", "locale", - function scripting() { + function scriptingChromium() { const defines = builder.merge(DEFINES, { CHROME: true, SKIP_BABEL: false, @@ -1270,7 +1270,7 @@ gulp.task( createTemporaryScriptingBundle(defines), ]); }, - function () { + function createChromium() { console.log(); console.log("### Building Chromium extension"); const defines = builder.merge(DEFINES, { @@ -1475,14 +1475,14 @@ gulp.task( "lib", gulp.series( "buildnumber", - function scripting() { + function scriptingLib() { const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true }); return merge([ buildDefaultPreferences(defines, "lib/"), createTemporaryScriptingBundle(defines), ]); }, - function () { + function createLib() { const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true }); return merge([ @@ -1497,7 +1497,7 @@ gulp.task( "lib-legacy", gulp.series( "buildnumber", - function scripting() { + function scriptingLibLegacy() { const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true, @@ -1508,7 +1508,7 @@ gulp.task( createTemporaryScriptingBundle(defines), ]); }, - function () { + function createLibLegacy() { const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true, @@ -1535,7 +1535,7 @@ function compressPublish(targetName, dir) { gulp.task( "publish", - gulp.series("generic", "generic-legacy", function (done) { + gulp.series("generic", "generic-legacy", function createPublish(done) { const version = JSON.parse( fs.readFileSync(BUILD_DIR + "version.json").toString() ).version; @@ -1567,7 +1567,7 @@ gulp.task("testing-pre", function (done) { gulp.task( "test", - gulp.series("testing-pre", "generic", "components", function () { + gulp.series("testing-pre", "generic", "components", function runTest() { return streamqueue( { objectMode: true }, createTestSource("unit"), @@ -1579,7 +1579,7 @@ gulp.task( gulp.task( "bottest", - gulp.series("testing-pre", "generic", "components", function () { + gulp.series("testing-pre", "generic", "components", function runBotTest() { return streamqueue( { objectMode: true }, createTestSource("unit", true), @@ -1592,49 +1592,64 @@ gulp.task( gulp.task( "browsertest", - gulp.series("testing-pre", "generic", "components", function () { - return createTestSource("browser"); - }) + gulp.series( + "testing-pre", + "generic", + "components", + function runBrowserTest() { + return createTestSource("browser"); + } + ) ); gulp.task( "unittest", - gulp.series("testing-pre", "generic", function () { + gulp.series("testing-pre", "generic", function runUnitTest() { return createTestSource("unit"); }) ); gulp.task( "integrationtest", - gulp.series("testing-pre", "generic", function () { + gulp.series("testing-pre", "generic", function runIntegrationTest() { return createTestSource("integration"); }) ); gulp.task( "fonttest", - gulp.series("testing-pre", function () { + gulp.series("testing-pre", function runFontTest() { return createTestSource("font"); }) ); gulp.task( "makeref", - gulp.series("testing-pre", "generic", "components", function (done) { - makeRef(done); - }) + gulp.series( + "testing-pre", + "generic", + "components", + function runMakeref(done) { + makeRef(done); + } + ) ); gulp.task( "botmakeref", - gulp.series("testing-pre", "generic", "components", function (done) { - makeRef(done, true); - }) + gulp.series( + "testing-pre", + "generic", + "components", + function runBotMakeref(done) { + makeRef(done, true); + } + ) ); gulp.task( "typestest-pre", - gulp.series("testing-pre", "generic", "types", function () { + gulp.series("testing-pre", "generic", "types", function createTypesTest() { const [packageJsonSrc] = packageBowerJson(); return merge([ packageJsonSrc.pipe(gulp.dest(TYPESTEST_DIR)), @@ -1654,7 +1669,7 @@ gulp.task( gulp.task( "typestest", - gulp.series("typestest-pre", function (done) { + gulp.series("typestest-pre", function runTypesTest(done) { exec('"node_modules/.bin/tsc" -p test/types', function (err, stdout) { if (err) { console.log(`Couldn't compile TypeScript test: ${stdout}`); @@ -1705,7 +1720,7 @@ gulp.task("baseline", function (done) { gulp.task( "unittestcli", - gulp.series("testing-pre", "lib-legacy", function (done) { + gulp.series("testing-pre", "lib-legacy", function runUnitTestCli(done) { const options = [ "node_modules/jasmine/bin/jasmine", "JASMINE_CONFIG_PATH=test/unit/clitests.json", @@ -1768,14 +1783,14 @@ gulp.task("lint", function (done) { gulp.task( "lint-chromium", gulp.series( - function scripting() { + function scriptingLintChromium() { const defines = builder.merge(DEFINES, { CHROME: true, SKIP_BABEL: false, }); return buildDefaultPreferences(defines, "lint-chromium/"); }, - function (done) { + function runLintChromium(done) { console.log(); console.log("### Checking supplemental Chromium files"); @@ -1796,13 +1811,13 @@ gulp.task( gulp.task( "dev-sandbox", gulp.series( - function scripting() { + function scriptingDevSandbox() { const defines = builder.merge(DEFINES, { GENERIC: true, TESTING: true }); return createTemporaryScriptingBundle(defines, { disableVersionInfo: true, }); }, - function () { + function createDevSandbox() { console.log(); console.log("### Building development sandbox"); @@ -1833,7 +1848,7 @@ gulp.task("watch-dev-sandbox", function () { gulp.task( "server", - gulp.parallel("watch-dev-sandbox", function () { + gulp.parallel("watch-dev-sandbox", function createServer() { console.log(); console.log("### Starting local server"); @@ -2041,7 +2056,7 @@ gulp.task( "minified", "minified-legacy", "types", - function () { + function createDist() { console.log(); console.log("### Cloning baseline distribution"); @@ -2139,7 +2154,7 @@ gulp.task( gulp.task( "dist-install", - gulp.series("dist-pre", function (done) { + gulp.series("dist-pre", function createDistInstall(done) { let distPath = DIST_DIR; const opts = {}; const installPath = process.env.PDFJS_INSTALL_PATH; @@ -2154,7 +2169,7 @@ gulp.task( gulp.task( "dist-repo-git", - gulp.series("dist-pre", function (done) { + gulp.series("dist-pre", function createDistRepoGit(done) { const VERSION = getVersionJSON().version; console.log(); @@ -2197,7 +2212,7 @@ gulp.task("dist", gulp.series("dist-repo-git")); gulp.task( "mozcentralbaseline", - gulp.series("baseline", function (done) { + gulp.series("baseline", function createMozcentralBaseline(done) { console.log(); console.log("### Creating mozcentral baseline environment"); @@ -2232,38 +2247,44 @@ gulp.task( gulp.task( "mozcentraldiff", - gulp.series("mozcentral", "mozcentralbaseline", function (done) { - console.log(); - console.log("### Creating mozcentral diff"); + gulp.series( + "mozcentral", + "mozcentralbaseline", + function createMozcentralDiff(done) { + console.log(); + console.log("### Creating mozcentral diff"); - // Create the diff between the current mozcentral build and the - // baseline mozcentral build, which both exist at this point. - // The mozcentral baseline directory is a Git repository, so we - // remove all files and copy the current mozcentral build files - // into it to create the diff. - rimraf.sync(MOZCENTRAL_BASELINE_DIR + "*"); + // Create the diff between the current mozcentral build and the + // baseline mozcentral build, which both exist at this point. + // The mozcentral baseline directory is a Git repository, so we + // remove all files and copy the current mozcentral build files + // into it to create the diff. + rimraf.sync(MOZCENTRAL_BASELINE_DIR + "*"); - gulp - .src([BUILD_DIR + "mozcentral/**/*"]) - .pipe(gulp.dest(MOZCENTRAL_BASELINE_DIR)) - .on("end", function () { - safeSpawnSync("git", ["add", "-A"], { cwd: MOZCENTRAL_BASELINE_DIR }); - const diff = safeSpawnSync( - "git", - ["diff", "--binary", "--cached", "--unified=8"], - { cwd: MOZCENTRAL_BASELINE_DIR } - ).stdout; + gulp + .src([BUILD_DIR + "mozcentral/**/*"]) + .pipe(gulp.dest(MOZCENTRAL_BASELINE_DIR)) + .on("end", function () { + safeSpawnSync("git", ["add", "-A"], { cwd: MOZCENTRAL_BASELINE_DIR }); + const diff = safeSpawnSync( + "git", + ["diff", "--binary", "--cached", "--unified=8"], + { cwd: MOZCENTRAL_BASELINE_DIR } + ).stdout; - createStringSource(MOZCENTRAL_DIFF_FILE, diff) - .pipe(gulp.dest(BUILD_DIR)) - .on("end", function () { - console.log( - "Result diff can be found at " + BUILD_DIR + MOZCENTRAL_DIFF_FILE - ); - done(); - }); - }); - }) + createStringSource(MOZCENTRAL_DIFF_FILE, diff) + .pipe(gulp.dest(BUILD_DIR)) + .on("end", function () { + console.log( + "Result diff can be found at " + + BUILD_DIR + + MOZCENTRAL_DIFF_FILE + ); + done(); + }); + }); + } + ) ); gulp.task("externaltest", function (done) { From 6c249f8e219d4239d8de778c1ba4052d025a5d69 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 4 Jun 2021 12:30:09 +0200 Subject: [PATCH 2/3] Clean-up `gulpfile.js` by removing most "-pre" tasks (issue 10362) Most of the `gulp` tasks with a "-pre" suffix, especially those related to the main build-targets, are no longer needed and can simply be inlined in their corresponding tasks. This is likely a left-over from older Gulp-versions, but currently it only adds unnecessary indirection. Furthermore, a number of the `gulp` tasks which are only used *internally* are converted to standard functions instead. This prevents them from being exposed "globally" and e.g. listed by `gulp default`. --- gulpfile.js | 316 ++++++++++++++++++++++++---------------------------- 1 file changed, 148 insertions(+), 168 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index fe1e09789..a2f75a750 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -597,14 +597,16 @@ function makeRef(done, bot) { gulp.task("default", function (done) { console.log("Available tasks:"); const tasks = Object.keys(gulp.registry().tasks()); - tasks.sort(); - tasks.forEach(function (taskName) { + for (const taskName of tasks.sort()) { + if (taskName.endsWith("-pre")) { + continue; + } console.log(" " + taskName); - }); + } done(); }); -gulp.task("buildnumber", function (done) { +function createBuildNumber(done) { console.log(); console.log("### Getting extension build number"); @@ -648,7 +650,7 @@ gulp.task("buildnumber", function (done) { }); } ); -}); +} function buildDefaultPreferences(defines, dir) { console.log(); @@ -827,7 +829,7 @@ function buildGeneric(defines, dir) { gulp.task( "generic", gulp.series( - "buildnumber", + createBuildNumber, "locale", function scriptingGeneric() { const defines = builder.merge(DEFINES, { GENERIC: true }); @@ -851,7 +853,7 @@ gulp.task( gulp.task( "generic-legacy", gulp.series( - "buildnumber", + createBuildNumber, "locale", function scriptingGenericLegacy() { const defines = builder.merge(DEFINES, { @@ -896,7 +898,7 @@ function buildComponents(defines, dir) { gulp.task( "components", - gulp.series("buildnumber", function createComponents() { + gulp.series(createBuildNumber, function createComponents() { console.log(); console.log("### Creating generic components"); const defines = builder.merge(DEFINES, { COMPONENTS: true, GENERIC: true }); @@ -907,7 +909,7 @@ gulp.task( gulp.task( "components-legacy", - gulp.series("buildnumber", function createComponentsLegacy() { + gulp.series(createBuildNumber, function createComponentsLegacy() { console.log(); console.log("### Creating generic (legacy) components"); const defines = builder.merge(DEFINES, { @@ -922,7 +924,7 @@ gulp.task( gulp.task( "image_decoders", - gulp.series("buildnumber", function createImageDecoders() { + gulp.series(createBuildNumber, function createImageDecoders() { console.log(); console.log("### Creating image decoders"); const defines = builder.merge(DEFINES, { @@ -938,7 +940,7 @@ gulp.task( gulp.task( "image_decoders-legacy", - gulp.series("buildnumber", function createImageDecodersLegacy() { + gulp.series(createBuildNumber, function createImageDecodersLegacy() { console.log(); console.log("### Creating (legacy) image decoders"); const defines = builder.merge(DEFINES, { @@ -991,58 +993,6 @@ function buildMinified(defines, dir) { ]); } -gulp.task( - "minified-pre", - gulp.series( - "buildnumber", - "locale", - function scriptingMinified() { - const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true }); - return merge([ - buildDefaultPreferences(defines, "minified/"), - createTemporaryScriptingBundle(defines), - ]); - }, - function createMinified() { - console.log(); - console.log("### Creating minified viewer"); - const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true }); - - return buildMinified(defines, MINIFIED_DIR); - } - ) -); - -gulp.task( - "minified-legacy-pre", - gulp.series( - "buildnumber", - "locale", - function scriptingMinifiedLegacy() { - const defines = builder.merge(DEFINES, { - MINIFIED: true, - GENERIC: true, - SKIP_BABEL: false, - }); - return merge([ - buildDefaultPreferences(defines, "minified-legacy/"), - createTemporaryScriptingBundle(defines), - ]); - }, - function createMinifiedLegacy() { - console.log(); - console.log("### Creating minified (legacy) viewer"); - const defines = builder.merge(DEFINES, { - MINIFIED: true, - GENERIC: true, - SKIP_BABEL: false, - }); - - return buildMinified(defines, MINIFIED_LEGACY_DIR); - } - ) -); - async function parseMinified(dir) { const pdfFile = fs.readFileSync(dir + "/build/pdf.js").toString(); const pdfWorkerFile = fs @@ -1116,18 +1066,62 @@ async function parseMinified(dir) { gulp.task( "minified", - gulp.series("minified-pre", async function minifiedPost(done) { - await parseMinified(MINIFIED_DIR); - done(); - }) + gulp.series( + createBuildNumber, + "locale", + function scriptingMinified() { + const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true }); + return merge([ + buildDefaultPreferences(defines, "minified/"), + createTemporaryScriptingBundle(defines), + ]); + }, + function createMinified() { + console.log(); + console.log("### Creating minified viewer"); + const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true }); + + return buildMinified(defines, MINIFIED_DIR); + }, + async function compressMinified(done) { + await parseMinified(MINIFIED_DIR); + done(); + } + ) ); gulp.task( "minified-legacy", - gulp.series("minified-legacy-pre", async function minifiedLegacyPost(done) { - await parseMinified(MINIFIED_LEGACY_DIR); - done(); - }) + gulp.series( + createBuildNumber, + "locale", + function scriptingMinifiedLegacy() { + const defines = builder.merge(DEFINES, { + MINIFIED: true, + GENERIC: true, + SKIP_BABEL: false, + }); + return merge([ + buildDefaultPreferences(defines, "minified-legacy/"), + createTemporaryScriptingBundle(defines), + ]); + }, + function createMinifiedLegacy() { + console.log(); + console.log("### Creating minified (legacy) viewer"); + const defines = builder.merge(DEFINES, { + MINIFIED: true, + GENERIC: true, + SKIP_BABEL: false, + }); + + return buildMinified(defines, MINIFIED_LEGACY_DIR); + }, + async function compressMinifiedLegacy(done) { + await parseMinified(MINIFIED_LEGACY_DIR); + done(); + } + ) ); function preprocessDefaultPreferences(content) { @@ -1163,9 +1157,9 @@ function preprocessDefaultPreferences(content) { } gulp.task( - "mozcentral-pre", + "mozcentral", gulp.series( - "buildnumber", + createBuildNumber, function scriptingMozcentral() { const defines = builder.merge(DEFINES, { MOZCENTRAL: true }); return buildDefaultPreferences(defines, "mozcentral/"); @@ -1253,12 +1247,10 @@ gulp.task( ) ); -gulp.task("mozcentral", gulp.series("mozcentral-pre")); - gulp.task( - "chromium-pre", + "chromium", gulp.series( - "buildnumber", + createBuildNumber, "locale", function scriptingChromium() { const defines = builder.merge(DEFINES, { @@ -1343,8 +1335,6 @@ gulp.task( ) ); -gulp.task("chromium", gulp.series("chromium-pre")); - gulp.task("jsdoc", function (done) { console.log(); console.log("### Generating documentation (JSDoc)"); @@ -1474,7 +1464,7 @@ function buildLib(defines, dir) { gulp.task( "lib", gulp.series( - "buildnumber", + createBuildNumber, function scriptingLib() { const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true }); return merge([ @@ -1496,7 +1486,7 @@ gulp.task( gulp.task( "lib-legacy", gulp.series( - "buildnumber", + createBuildNumber, function scriptingLibLegacy() { const defines = builder.merge(DEFINES, { GENERIC: true, @@ -1556,18 +1546,18 @@ gulp.task( }) ); -gulp.task("testing-pre", function (done) { +function setTestEnv(done) { process.env.TESTING = "true"; // TODO: Re-write the relevant unit-tests, which are using `new Date(...)`, // to not required the following time-zone hack since it doesn't work // when the unit-tests are run directly in the browser. process.env.TZ = "UTC"; done(); -}); +} gulp.task( "test", - gulp.series("testing-pre", "generic", "components", function runTest() { + gulp.series(setTestEnv, "generic", "components", function runTest() { return streamqueue( { objectMode: true }, createTestSource("unit"), @@ -1579,7 +1569,7 @@ gulp.task( gulp.task( "bottest", - gulp.series("testing-pre", "generic", "components", function runBotTest() { + gulp.series(setTestEnv, "generic", "components", function runBotTest() { return streamqueue( { objectMode: true }, createTestSource("unit", true), @@ -1592,53 +1582,43 @@ gulp.task( gulp.task( "browsertest", - gulp.series( - "testing-pre", - "generic", - "components", - function runBrowserTest() { - return createTestSource("browser"); - } - ) + gulp.series(setTestEnv, "generic", "components", function runBrowserTest() { + return createTestSource("browser"); + }) ); gulp.task( "unittest", - gulp.series("testing-pre", "generic", function runUnitTest() { + gulp.series(setTestEnv, "generic", function runUnitTest() { return createTestSource("unit"); }) ); gulp.task( "integrationtest", - gulp.series("testing-pre", "generic", function runIntegrationTest() { + gulp.series(setTestEnv, "generic", function runIntegrationTest() { return createTestSource("integration"); }) ); gulp.task( "fonttest", - gulp.series("testing-pre", function runFontTest() { + gulp.series(setTestEnv, function runFontTest() { return createTestSource("font"); }) ); gulp.task( "makeref", - gulp.series( - "testing-pre", - "generic", - "components", - function runMakeref(done) { - makeRef(done); - } - ) + gulp.series(setTestEnv, "generic", "components", function runMakeref(done) { + makeRef(done); + }) ); gulp.task( "botmakeref", gulp.series( - "testing-pre", + setTestEnv, "generic", "components", function runBotMakeref(done) { @@ -1647,39 +1627,40 @@ gulp.task( ) ); -gulp.task( - "typestest-pre", - gulp.series("testing-pre", "generic", "types", function createTypesTest() { - const [packageJsonSrc] = packageBowerJson(); - return merge([ - packageJsonSrc.pipe(gulp.dest(TYPESTEST_DIR)), - gulp - .src([ - GENERIC_DIR + "build/pdf.js", - GENERIC_DIR + "build/pdf.worker.js", - SRC_DIR + "pdf.worker.entry.js", - ]) - .pipe(gulp.dest(TYPESTEST_DIR + "build/")), - gulp - .src(TYPES_DIR + "**/*", { base: TYPES_DIR }) - .pipe(gulp.dest(TYPESTEST_DIR + "types/")), - ]); - }) -); - gulp.task( "typestest", - gulp.series("typestest-pre", function runTypesTest(done) { - exec('"node_modules/.bin/tsc" -p test/types', function (err, stdout) { - if (err) { - console.log(`Couldn't compile TypeScript test: ${stdout}`); - } - done(err); - }); - }) + gulp.series( + setTestEnv, + "generic", + "types", + function createTypesTest() { + const [packageJsonSrc] = packageBowerJson(); + return merge([ + packageJsonSrc.pipe(gulp.dest(TYPESTEST_DIR)), + gulp + .src([ + GENERIC_DIR + "build/pdf.js", + GENERIC_DIR + "build/pdf.worker.js", + SRC_DIR + "pdf.worker.entry.js", + ]) + .pipe(gulp.dest(TYPESTEST_DIR + "build/")), + gulp + .src(TYPES_DIR + "**/*", { base: TYPES_DIR }) + .pipe(gulp.dest(TYPESTEST_DIR + "types/")), + ]); + }, + function runTypesTest(done) { + exec('"node_modules/.bin/tsc" -p test/types', function (err, stdout) { + if (err) { + console.log(`Couldn't compile TypeScript test: ${stdout}`); + } + done(err); + }); + } + ) ); -gulp.task("baseline", function (done) { +function createBaseline(done) { console.log(); console.log("### Creating baseline environment"); @@ -1716,11 +1697,11 @@ gulp.task("baseline", function (done) { } ); }); -}); +} gulp.task( "unittestcli", - gulp.series("testing-pre", "lib-legacy", function runUnitTestCli(done) { + gulp.series(setTestEnv, "lib-legacy", function runUnitTestCli(done) { const options = [ "node_modules/jasmine/bin/jasmine", "JASMINE_CONFIG_PATH=test/unit/clitests.json", @@ -1833,30 +1814,31 @@ gulp.task( ) ); -gulp.task("watch-dev-sandbox", function () { - gulp.watch( - [ - "src/pdf.{sandbox,sandbox.external,scripting}.js", - "src/scripting_api/*.js", - "src/shared/scripting_utils.js", - "external/quickjs/*.js", - ], - { ignoreInitial: false }, - gulp.series("dev-sandbox") - ); -}); - gulp.task( "server", - gulp.parallel("watch-dev-sandbox", function createServer() { - console.log(); - console.log("### Starting local server"); + gulp.parallel( + function watchDevSandbox() { + gulp.watch( + [ + "src/pdf.{sandbox,sandbox.external,scripting}.js", + "src/scripting_api/*.js", + "src/shared/scripting_utils.js", + "external/quickjs/*.js", + ], + { ignoreInitial: false }, + gulp.series("dev-sandbox") + ); + }, + function createServer() { + console.log(); + console.log("### Starting local server"); - const WebServer = require("./test/webserver.js").WebServer; - const server = new WebServer(); - server.port = 8888; - server.start(); - }) + const WebServer = require("./test/webserver.js").WebServer; + const server = new WebServer(); + server.port = 8888; + server.start(); + } + ) ); gulp.task("clean", function (done) { @@ -1889,7 +1871,7 @@ gulp.task("importl10n", function (done) { locales.downloadL10n(L10N_DIR, done); }); -gulp.task("gh-pages-prepare", function () { +function ghPagesPrepare() { console.log(); console.log("### Creating web site"); @@ -1910,7 +1892,7 @@ gulp.task("gh-pages-prepare", function () { .src(JSDOC_BUILD_DIR + "**/*", { base: JSDOC_BUILD_DIR }) .pipe(gulp.dest(GH_PAGES_DIR + "api/draft/")), ]); -}); +} gulp.task("wintersmith", function (done) { const wintersmith = require("wintersmith"); @@ -1952,7 +1934,7 @@ gulp.task("wintersmith", function (done) { }); }); -gulp.task("gh-pages-git", function (done) { +function ghPagesGit(done) { const VERSION = getVersionJSON().version; const reason = process.env.PDFJS_UPDATE_REASON; @@ -1977,7 +1959,7 @@ gulp.task("gh-pages-git", function (done) { console.log(); console.log("Website built in " + GH_PAGES_DIR); done(); -}); +} gulp.task( "web", @@ -1985,9 +1967,9 @@ gulp.task( "generic", "generic-legacy", "jsdoc", - "gh-pages-prepare", + ghPagesPrepare, "wintersmith", - "gh-pages-git" + ghPagesGit ) ); @@ -2168,8 +2150,8 @@ gulp.task( ); gulp.task( - "dist-repo-git", - gulp.series("dist-pre", function createDistRepoGit(done) { + "dist", + gulp.series("dist-pre", function createDist(done) { const VERSION = getVersionJSON().version; console.log(); @@ -2208,11 +2190,9 @@ gulp.task( }) ); -gulp.task("dist", gulp.series("dist-repo-git")); - gulp.task( "mozcentralbaseline", - gulp.series("baseline", function createMozcentralBaseline(done) { + gulp.series(createBaseline, function createMozcentralBaseline(done) { console.log(); console.log("### Creating mozcentral baseline environment"); From 66a56718476d9622aed2d5a2a9b38d29c2d47407 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 4 Jun 2021 12:53:19 +0200 Subject: [PATCH 3/3] Remove `gulp makefile`, since it's broken and unused Looking at the history of the code, this `gulp` task was *accidentally* broken in the Gulp 4 upgrade in PR 10266 (all the way back in 2018). Given that no one has either noticed and/or complained about this since, it's safe to assume that it's completely unused, hence why I suggest that we just remove this `gulp` task (rather than fixing it). --- gulpfile.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index a2f75a750..7b8b46727 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -13,7 +13,6 @@ * limitations under the License. */ /* eslint-env node */ -/* globals target */ "use strict"; @@ -1848,17 +1847,6 @@ gulp.task("clean", function (done) { rimraf(BUILD_DIR, done); }); -gulp.task("makefile", function () { - let makefileContent = "help:\n\tgulp\n\n"; - const targetsNames = []; - for (const i in target) { - makefileContent += i + ":\n\tgulp " + i + "\n\n"; - targetsNames.push(i); - } - makefileContent += ".PHONY: " + targetsNames.join(" ") + "\n"; - return createStringSource("Makefile", makefileContent).pipe(gulp.dest(".")); -}); - gulp.task("importl10n", function (done) { const locales = require("./external/importL10n/locales.js");