Skip to content

Commit fb85c2d

Browse files
committed
Fix the gulp types task to run on Windows, and place the TypeScript definitions correctly in pdfjs-dist
- Fix the `gulp types` task to run on Windows. Currently this fails, and the solution was to "borrow" the same formatting as used in the `gulp jsdoc` task. - Place the TypeScript definitions in their own `types` directory, when building `pdfjs-dist`. These should *not* be cluttering the main `build` directory, especially since the generated TypeScript definitions consists of *multiple folders*. (Only if the TypeScript definitions would be concatenated into *a single file*, would placing them directly in `pdfjs-dist/build` be acceptable.)
1 parent 71f8e1f commit fb85c2d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

gulpfile.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ gulp.task("types", function (done) {
11551155
"forceConsistentCasingInFileNames",
11561156
"emitDeclarationOnly",
11571157
].join(" --");
1158-
exec(`node_modules/.bin/tsc --${args} src/pdf.js`, done);
1158+
exec(`"node_modules/.bin/tsc" --${args} src/pdf.js`, done);
11591159
});
11601160

11611161
function buildLib(defines, dir) {
@@ -1366,15 +1366,17 @@ gulp.task(
13661366
SRC_DIR + "pdf.worker.entry.js",
13671367
])
13681368
.pipe(gulp.dest(TYPESTEST_DIR + "build/")),
1369-
gulp.src(TYPES_DIR + "**/**").pipe(gulp.dest(TYPESTEST_DIR + "build/")),
1369+
gulp
1370+
.src(TYPES_DIR + "**/*", { base: TYPES_DIR })
1371+
.pipe(gulp.dest(TYPESTEST_DIR + "types/")),
13701372
]);
13711373
})
13721374
);
13731375

13741376
gulp.task(
13751377
"typestest",
13761378
gulp.series("typestest-pre", function (done) {
1377-
exec("node_modules/.bin/tsc -p test/types", function (err, stdout) {
1379+
exec('"node_modules/.bin/tsc" -p test/types', function (err, stdout) {
13781380
if (err) {
13791381
console.log(`Couldn't compile TypeScript test: ${stdout}`);
13801382
}
@@ -1625,17 +1627,19 @@ gulp.task(
16251627

16261628
function packageBowerJson() {
16271629
var VERSION = getVersionJSON().version;
1630+
16281631
var DIST_NAME = "pdfjs-dist";
16291632
var DIST_DESCRIPTION = "Generic build of Mozilla's PDF.js library.";
16301633
var DIST_KEYWORDS = ["Mozilla", "pdf", "pdf.js"];
16311634
var DIST_HOMEPAGE = "http://mozilla.github.io/pdf.js/";
16321635
var DIST_BUGS_URL = "https://github.com/mozilla/pdf.js/issues";
16331636
var DIST_LICENSE = "Apache-2.0";
1637+
16341638
var npmManifest = {
16351639
name: DIST_NAME,
16361640
version: VERSION,
16371641
main: "build/pdf.js",
1638-
types: "build/pdf.d.ts",
1642+
types: "types/pdf.d.ts",
16391643
description: DIST_DESCRIPTION,
16401644
keywords: DIST_KEYWORDS,
16411645
homepage: DIST_HOMEPAGE,
@@ -1655,6 +1659,7 @@ function packageBowerJson() {
16551659
url: DIST_REPO_URL,
16561660
},
16571661
};
1662+
16581663
var bowerManifest = {
16591664
name: DIST_NAME,
16601665
version: VERSION,
@@ -1747,7 +1752,9 @@ gulp.task(
17471752
gulp
17481753
.src(LIB_DIR + "**/*", { base: LIB_DIR })
17491754
.pipe(gulp.dest(DIST_DIR + "lib/")),
1750-
gulp.src(TYPES_DIR + "**/**").pipe(gulp.dest(DIST_DIR + "build/")),
1755+
gulp
1756+
.src(TYPES_DIR + "**/*", { base: TYPES_DIR })
1757+
.pipe(gulp.dest(DIST_DIR + "types/")),
17511758
]);
17521759
}
17531760
)

0 commit comments

Comments
 (0)