Replace anonymous functions in gulpfile.js with named functions (issue 10362)

This replaces all of the `Starting '<anonymous>'...` lines in the output, when running various `gulp` tasks, with more meaningful function names.
This commit is contained in:
Jonas Jenwald 2021-06-03 15:44:17 +02:00
parent 9165dc0659
commit 92434b1eb4

View File

@ -829,14 +829,14 @@ gulp.task(
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"locale", "locale",
function scripting() { function scriptingGeneric() {
const defines = builder.merge(DEFINES, { GENERIC: true }); const defines = builder.merge(DEFINES, { GENERIC: true });
return merge([ return merge([
buildDefaultPreferences(defines, "generic/"), buildDefaultPreferences(defines, "generic/"),
createTemporaryScriptingBundle(defines), createTemporaryScriptingBundle(defines),
]); ]);
}, },
function () { function createGeneric() {
console.log(); console.log();
console.log("### Creating generic viewer"); console.log("### Creating generic viewer");
const defines = builder.merge(DEFINES, { GENERIC: true }); const defines = builder.merge(DEFINES, { GENERIC: true });
@ -853,7 +853,7 @@ gulp.task(
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"locale", "locale",
function scripting() { function scriptingGenericLegacy() {
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
GENERIC: true, GENERIC: true,
SKIP_BABEL: false, SKIP_BABEL: false,
@ -863,7 +863,7 @@ gulp.task(
createTemporaryScriptingBundle(defines), createTemporaryScriptingBundle(defines),
]); ]);
}, },
function () { function createGenericLegacy() {
console.log(); console.log();
console.log("### Creating generic (legacy) viewer"); console.log("### Creating generic (legacy) viewer");
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
@ -896,7 +896,7 @@ function buildComponents(defines, dir) {
gulp.task( gulp.task(
"components", "components",
gulp.series("buildnumber", function () { gulp.series("buildnumber", function createComponents() {
console.log(); console.log();
console.log("### Creating generic components"); console.log("### Creating generic components");
const defines = builder.merge(DEFINES, { COMPONENTS: true, GENERIC: true }); const defines = builder.merge(DEFINES, { COMPONENTS: true, GENERIC: true });
@ -907,7 +907,7 @@ gulp.task(
gulp.task( gulp.task(
"components-legacy", "components-legacy",
gulp.series("buildnumber", function () { gulp.series("buildnumber", function createComponentsLegacy() {
console.log(); console.log();
console.log("### Creating generic (legacy) components"); console.log("### Creating generic (legacy) components");
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
@ -922,7 +922,7 @@ gulp.task(
gulp.task( gulp.task(
"image_decoders", "image_decoders",
gulp.series("buildnumber", function () { gulp.series("buildnumber", function createImageDecoders() {
console.log(); console.log();
console.log("### Creating image decoders"); console.log("### Creating image decoders");
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
@ -938,7 +938,7 @@ gulp.task(
gulp.task( gulp.task(
"image_decoders-legacy", "image_decoders-legacy",
gulp.series("buildnumber", function () { gulp.series("buildnumber", function createImageDecodersLegacy() {
console.log(); console.log();
console.log("### Creating (legacy) image decoders"); console.log("### Creating (legacy) image decoders");
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
@ -996,14 +996,14 @@ gulp.task(
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"locale", "locale",
function scripting() { function scriptingMinified() {
const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true }); const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true });
return merge([ return merge([
buildDefaultPreferences(defines, "minified/"), buildDefaultPreferences(defines, "minified/"),
createTemporaryScriptingBundle(defines), createTemporaryScriptingBundle(defines),
]); ]);
}, },
function () { function createMinified() {
console.log(); console.log();
console.log("### Creating minified viewer"); console.log("### Creating minified viewer");
const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true }); const defines = builder.merge(DEFINES, { MINIFIED: true, GENERIC: true });
@ -1018,7 +1018,7 @@ gulp.task(
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"locale", "locale",
function scripting() { function scriptingMinifiedLegacy() {
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
MINIFIED: true, MINIFIED: true,
GENERIC: true, GENERIC: true,
@ -1029,7 +1029,7 @@ gulp.task(
createTemporaryScriptingBundle(defines), createTemporaryScriptingBundle(defines),
]); ]);
}, },
function () { function createMinifiedLegacy() {
console.log(); console.log();
console.log("### Creating minified (legacy) viewer"); console.log("### Creating minified (legacy) viewer");
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
@ -1116,7 +1116,7 @@ async function parseMinified(dir) {
gulp.task( gulp.task(
"minified", "minified",
gulp.series("minified-pre", async function (done) { gulp.series("minified-pre", async function minifiedPost(done) {
await parseMinified(MINIFIED_DIR); await parseMinified(MINIFIED_DIR);
done(); done();
}) })
@ -1124,7 +1124,7 @@ gulp.task(
gulp.task( gulp.task(
"minified-legacy", "minified-legacy",
gulp.series("minified-legacy-pre", async function (done) { gulp.series("minified-legacy-pre", async function minifiedLegacyPost(done) {
await parseMinified(MINIFIED_LEGACY_DIR); await parseMinified(MINIFIED_LEGACY_DIR);
done(); done();
}) })
@ -1166,11 +1166,11 @@ gulp.task(
"mozcentral-pre", "mozcentral-pre",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
function scripting() { function scriptingMozcentral() {
const defines = builder.merge(DEFINES, { MOZCENTRAL: true }); const defines = builder.merge(DEFINES, { MOZCENTRAL: true });
return buildDefaultPreferences(defines, "mozcentral/"); return buildDefaultPreferences(defines, "mozcentral/");
}, },
function () { function createMozcentral() {
console.log(); console.log();
console.log("### Building mozilla-central extension"); console.log("### Building mozilla-central extension");
const defines = builder.merge(DEFINES, { MOZCENTRAL: true }); const defines = builder.merge(DEFINES, { MOZCENTRAL: true });
@ -1260,7 +1260,7 @@ gulp.task(
gulp.series( gulp.series(
"buildnumber", "buildnumber",
"locale", "locale",
function scripting() { function scriptingChromium() {
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
CHROME: true, CHROME: true,
SKIP_BABEL: false, SKIP_BABEL: false,
@ -1270,7 +1270,7 @@ gulp.task(
createTemporaryScriptingBundle(defines), createTemporaryScriptingBundle(defines),
]); ]);
}, },
function () { function createChromium() {
console.log(); console.log();
console.log("### Building Chromium extension"); console.log("### Building Chromium extension");
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
@ -1475,14 +1475,14 @@ gulp.task(
"lib", "lib",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
function scripting() { function scriptingLib() {
const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true }); const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true });
return merge([ return merge([
buildDefaultPreferences(defines, "lib/"), buildDefaultPreferences(defines, "lib/"),
createTemporaryScriptingBundle(defines), createTemporaryScriptingBundle(defines),
]); ]);
}, },
function () { function createLib() {
const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true }); const defines = builder.merge(DEFINES, { GENERIC: true, LIB: true });
return merge([ return merge([
@ -1497,7 +1497,7 @@ gulp.task(
"lib-legacy", "lib-legacy",
gulp.series( gulp.series(
"buildnumber", "buildnumber",
function scripting() { function scriptingLibLegacy() {
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
GENERIC: true, GENERIC: true,
LIB: true, LIB: true,
@ -1508,7 +1508,7 @@ gulp.task(
createTemporaryScriptingBundle(defines), createTemporaryScriptingBundle(defines),
]); ]);
}, },
function () { function createLibLegacy() {
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
GENERIC: true, GENERIC: true,
LIB: true, LIB: true,
@ -1535,7 +1535,7 @@ function compressPublish(targetName, dir) {
gulp.task( gulp.task(
"publish", "publish",
gulp.series("generic", "generic-legacy", function (done) { gulp.series("generic", "generic-legacy", function createPublish(done) {
const version = JSON.parse( const version = JSON.parse(
fs.readFileSync(BUILD_DIR + "version.json").toString() fs.readFileSync(BUILD_DIR + "version.json").toString()
).version; ).version;
@ -1567,7 +1567,7 @@ gulp.task("testing-pre", function (done) {
gulp.task( gulp.task(
"test", "test",
gulp.series("testing-pre", "generic", "components", function () { gulp.series("testing-pre", "generic", "components", function runTest() {
return streamqueue( return streamqueue(
{ objectMode: true }, { objectMode: true },
createTestSource("unit"), createTestSource("unit"),
@ -1579,7 +1579,7 @@ gulp.task(
gulp.task( gulp.task(
"bottest", "bottest",
gulp.series("testing-pre", "generic", "components", function () { gulp.series("testing-pre", "generic", "components", function runBotTest() {
return streamqueue( return streamqueue(
{ objectMode: true }, { objectMode: true },
createTestSource("unit", true), createTestSource("unit", true),
@ -1592,49 +1592,64 @@ gulp.task(
gulp.task( gulp.task(
"browsertest", "browsertest",
gulp.series("testing-pre", "generic", "components", function () { gulp.series(
return createTestSource("browser"); "testing-pre",
}) "generic",
"components",
function runBrowserTest() {
return createTestSource("browser");
}
)
); );
gulp.task( gulp.task(
"unittest", "unittest",
gulp.series("testing-pre", "generic", function () { gulp.series("testing-pre", "generic", function runUnitTest() {
return createTestSource("unit"); return createTestSource("unit");
}) })
); );
gulp.task( gulp.task(
"integrationtest", "integrationtest",
gulp.series("testing-pre", "generic", function () { gulp.series("testing-pre", "generic", function runIntegrationTest() {
return createTestSource("integration"); return createTestSource("integration");
}) })
); );
gulp.task( gulp.task(
"fonttest", "fonttest",
gulp.series("testing-pre", function () { gulp.series("testing-pre", function runFontTest() {
return createTestSource("font"); return createTestSource("font");
}) })
); );
gulp.task( gulp.task(
"makeref", "makeref",
gulp.series("testing-pre", "generic", "components", function (done) { gulp.series(
makeRef(done); "testing-pre",
}) "generic",
"components",
function runMakeref(done) {
makeRef(done);
}
)
); );
gulp.task( gulp.task(
"botmakeref", "botmakeref",
gulp.series("testing-pre", "generic", "components", function (done) { gulp.series(
makeRef(done, true); "testing-pre",
}) "generic",
"components",
function runBotMakeref(done) {
makeRef(done, true);
}
)
); );
gulp.task( gulp.task(
"typestest-pre", "typestest-pre",
gulp.series("testing-pre", "generic", "types", function () { gulp.series("testing-pre", "generic", "types", function createTypesTest() {
const [packageJsonSrc] = packageBowerJson(); const [packageJsonSrc] = packageBowerJson();
return merge([ return merge([
packageJsonSrc.pipe(gulp.dest(TYPESTEST_DIR)), packageJsonSrc.pipe(gulp.dest(TYPESTEST_DIR)),
@ -1654,7 +1669,7 @@ gulp.task(
gulp.task( gulp.task(
"typestest", "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) { exec('"node_modules/.bin/tsc" -p test/types', function (err, stdout) {
if (err) { if (err) {
console.log(`Couldn't compile TypeScript test: ${stdout}`); console.log(`Couldn't compile TypeScript test: ${stdout}`);
@ -1705,7 +1720,7 @@ gulp.task("baseline", function (done) {
gulp.task( gulp.task(
"unittestcli", "unittestcli",
gulp.series("testing-pre", "lib-legacy", function (done) { gulp.series("testing-pre", "lib-legacy", function runUnitTestCli(done) {
const options = [ const options = [
"node_modules/jasmine/bin/jasmine", "node_modules/jasmine/bin/jasmine",
"JASMINE_CONFIG_PATH=test/unit/clitests.json", "JASMINE_CONFIG_PATH=test/unit/clitests.json",
@ -1768,14 +1783,14 @@ gulp.task("lint", function (done) {
gulp.task( gulp.task(
"lint-chromium", "lint-chromium",
gulp.series( gulp.series(
function scripting() { function scriptingLintChromium() {
const defines = builder.merge(DEFINES, { const defines = builder.merge(DEFINES, {
CHROME: true, CHROME: true,
SKIP_BABEL: false, SKIP_BABEL: false,
}); });
return buildDefaultPreferences(defines, "lint-chromium/"); return buildDefaultPreferences(defines, "lint-chromium/");
}, },
function (done) { function runLintChromium(done) {
console.log(); console.log();
console.log("### Checking supplemental Chromium files"); console.log("### Checking supplemental Chromium files");
@ -1796,13 +1811,13 @@ gulp.task(
gulp.task( gulp.task(
"dev-sandbox", "dev-sandbox",
gulp.series( gulp.series(
function scripting() { function scriptingDevSandbox() {
const defines = builder.merge(DEFINES, { GENERIC: true, TESTING: true }); const defines = builder.merge(DEFINES, { GENERIC: true, TESTING: true });
return createTemporaryScriptingBundle(defines, { return createTemporaryScriptingBundle(defines, {
disableVersionInfo: true, disableVersionInfo: true,
}); });
}, },
function () { function createDevSandbox() {
console.log(); console.log();
console.log("### Building development sandbox"); console.log("### Building development sandbox");
@ -1833,7 +1848,7 @@ gulp.task("watch-dev-sandbox", function () {
gulp.task( gulp.task(
"server", "server",
gulp.parallel("watch-dev-sandbox", function () { gulp.parallel("watch-dev-sandbox", function createServer() {
console.log(); console.log();
console.log("### Starting local server"); console.log("### Starting local server");
@ -2041,7 +2056,7 @@ gulp.task(
"minified", "minified",
"minified-legacy", "minified-legacy",
"types", "types",
function () { function createDist() {
console.log(); console.log();
console.log("### Cloning baseline distribution"); console.log("### Cloning baseline distribution");
@ -2139,7 +2154,7 @@ gulp.task(
gulp.task( gulp.task(
"dist-install", "dist-install",
gulp.series("dist-pre", function (done) { gulp.series("dist-pre", function createDistInstall(done) {
let distPath = DIST_DIR; let distPath = DIST_DIR;
const opts = {}; const opts = {};
const installPath = process.env.PDFJS_INSTALL_PATH; const installPath = process.env.PDFJS_INSTALL_PATH;
@ -2154,7 +2169,7 @@ gulp.task(
gulp.task( gulp.task(
"dist-repo-git", "dist-repo-git",
gulp.series("dist-pre", function (done) { gulp.series("dist-pre", function createDistRepoGit(done) {
const VERSION = getVersionJSON().version; const VERSION = getVersionJSON().version;
console.log(); console.log();
@ -2197,7 +2212,7 @@ gulp.task("dist", gulp.series("dist-repo-git"));
gulp.task( gulp.task(
"mozcentralbaseline", "mozcentralbaseline",
gulp.series("baseline", function (done) { gulp.series("baseline", function createMozcentralBaseline(done) {
console.log(); console.log();
console.log("### Creating mozcentral baseline environment"); console.log("### Creating mozcentral baseline environment");
@ -2232,38 +2247,44 @@ gulp.task(
gulp.task( gulp.task(
"mozcentraldiff", "mozcentraldiff",
gulp.series("mozcentral", "mozcentralbaseline", function (done) { gulp.series(
console.log(); "mozcentral",
console.log("### Creating mozcentral diff"); "mozcentralbaseline",
function createMozcentralDiff(done) {
console.log();
console.log("### Creating mozcentral diff");
// Create the diff between the current mozcentral build and the // Create the diff between the current mozcentral build and the
// baseline mozcentral build, which both exist at this point. // baseline mozcentral build, which both exist at this point.
// The mozcentral baseline directory is a Git repository, so we // The mozcentral baseline directory is a Git repository, so we
// remove all files and copy the current mozcentral build files // remove all files and copy the current mozcentral build files
// into it to create the diff. // into it to create the diff.
rimraf.sync(MOZCENTRAL_BASELINE_DIR + "*"); rimraf.sync(MOZCENTRAL_BASELINE_DIR + "*");
gulp gulp
.src([BUILD_DIR + "mozcentral/**/*"]) .src([BUILD_DIR + "mozcentral/**/*"])
.pipe(gulp.dest(MOZCENTRAL_BASELINE_DIR)) .pipe(gulp.dest(MOZCENTRAL_BASELINE_DIR))
.on("end", function () { .on("end", function () {
safeSpawnSync("git", ["add", "-A"], { cwd: MOZCENTRAL_BASELINE_DIR }); safeSpawnSync("git", ["add", "-A"], { cwd: MOZCENTRAL_BASELINE_DIR });
const diff = safeSpawnSync( const diff = safeSpawnSync(
"git", "git",
["diff", "--binary", "--cached", "--unified=8"], ["diff", "--binary", "--cached", "--unified=8"],
{ cwd: MOZCENTRAL_BASELINE_DIR } { cwd: MOZCENTRAL_BASELINE_DIR }
).stdout; ).stdout;
createStringSource(MOZCENTRAL_DIFF_FILE, diff) createStringSource(MOZCENTRAL_DIFF_FILE, diff)
.pipe(gulp.dest(BUILD_DIR)) .pipe(gulp.dest(BUILD_DIR))
.on("end", function () { .on("end", function () {
console.log( console.log(
"Result diff can be found at " + BUILD_DIR + MOZCENTRAL_DIFF_FILE "Result diff can be found at " +
); BUILD_DIR +
done(); MOZCENTRAL_DIFF_FILE
}); );
}); done();
}) });
});
}
)
); );
gulp.task("externaltest", function (done) { gulp.task("externaltest", function (done) {