Skip to content

Commit d6fad2a

Browse files
authored
fix(wpt): download files as buffer instead of text (#535)
There are binary files in the WPT repository and downloading them as text corrupts them. Refs: nodejs/node#37294
1 parent 059c138 commit d6fad2a

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/github/tree.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ class GitHubTree {
5858
return `${this.repoUrl}/tree/${commit.slice(0, 10)}/${this.path}`;
5959
}
6060

61-
async text(assetPath) {
61+
async buffer(assetPath) {
6262
await this.getLastCommit();
6363
const url = this.getAssetUrl(assetPath);
64-
return this.request.text(url);
64+
return this.request.buffer(url);
6565
}
6666

6767
/**

lib/request.js

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class Request {
3737
return wrappedFetch(url, options);
3838
}
3939

40+
async buffer(url, options = {}) {
41+
return this.fetch(url, options).then(res => res.buffer());
42+
}
43+
4044
async text(url, options = {}) {
4145
return this.fetch(url, options).then(res => res.text());
4246
}

lib/wpt/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class WPTUpdater {
4949
// If filepath starts with '/', the path is relative to WPT project root,
5050
// otherwise it's relative to the path of this updater
5151
async pullTextFile(dest, filepath) {
52-
const content = await this.tree.text(filepath);
52+
const content = await this.tree.buffer(filepath);
5353
const filename = path.join(dest, filepath);
5454
writeFile(filename, content);
5555
this.cli.updateSpinner(`Downloaded ${filename}`);

0 commit comments

Comments
 (0)