diff --git a/gulpfile.js b/gulpfile.js index b15db4ee8..39a39bd90 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -63,7 +63,8 @@ var GH_PAGES_DIR = BUILD_DIR + "gh-pages/"; var SRC_DIR = "src/"; var LIB_DIR = BUILD_DIR + "lib/"; var DIST_DIR = BUILD_DIR + "dist/"; -var TYPES_BUILD_DIR = BUILD_DIR + "types/"; +var TYPES_DIR = BUILD_DIR + "types/"; +var TYPESTEST_DIR = BUILD_DIR + "typestest/"; var COMMON_WEB_FILES = ["web/images/*.{png,svg,gif,cur}", "web/debugger.js"]; var MOZCENTRAL_DIFF_FILE = "mozcentral.diff"; @@ -1143,12 +1144,12 @@ gulp.task("jsdoc", function (done) { }); gulp.task("types", function (done) { - console.log("### Generating typescript definitions using tsc"); - var args = [ + console.log("### Generating TypeScript definitions using `tsc`"); + const args = [ "target ES2020", "allowJS", "declaration", - `outDir ${TYPES_BUILD_DIR}`, + `outDir ${TYPES_DIR}`, "strict", "esModuleInterop", "forceConsistentCasingInFileNames", @@ -1352,40 +1353,34 @@ gulp.task( }) ); +gulp.task( + "typestest-pre", + gulp.series("testing-pre", "generic", "types", function () { + 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 + "**/**").pipe(gulp.dest(TYPESTEST_DIR + "build/")), + ]); + }) +); + gulp.task( "typestest", - gulp.series( - "testing-pre", - "generic", - "types", - - function () { - var packageJsonSrc = packageBowerJson()[0]; - var TYPESTEST_DIR = BUILD_DIR + "typestest/"; - - 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_BUILD_DIR + "**/**") - .pipe(gulp.dest(TYPESTEST_DIR + "build/")), - ]); - }, - function (done) { - exec(`node_modules/.bin/tsc -p test/types`, function (err, stdout) { - if (err !== null) { - console.log("couldn't compile typescript test: " + stdout); - } - done(err); - }); - } - ) + gulp.series("typestest-pre", function (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) { @@ -1752,9 +1747,7 @@ gulp.task( gulp .src(LIB_DIR + "**/*", { base: LIB_DIR }) .pipe(gulp.dest(DIST_DIR + "lib/")), - gulp - .src(TYPES_BUILD_DIR + "**/**") - .pipe(gulp.dest(DIST_DIR + "build/")), + gulp.src(TYPES_DIR + "**/**").pipe(gulp.dest(DIST_DIR + "build/")), ]); } )