From 5479fb1b58a9528c4718c43d3e6da420fef4b65e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sun, 21 Feb 2021 16:48:38 +0100 Subject: [PATCH] fix(wpt): download files as buffer instead of text There are binary files in the WPT repository and downloading them as text corrupts them. Refs: https://github.com/nodejs/node/pull/37294 --- lib/github/tree.js | 4 ++-- lib/request.js | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/github/tree.js b/lib/github/tree.js index 79b58192..a64bb22f 100644 --- a/lib/github/tree.js +++ b/lib/github/tree.js @@ -58,10 +58,10 @@ class GitHubTree { return `${this.repoUrl}/tree/${commit.slice(0, 10)}/${this.path}`; } - async text(assetPath) { + async buffer(assetPath) { await this.getLastCommit(); const url = this.getAssetUrl(assetPath); - return this.request.text(url); + return this.request.buffer(url); } /** diff --git a/lib/request.js b/lib/request.js index e33b9082..8ba878b8 100644 --- a/lib/request.js +++ b/lib/request.js @@ -37,6 +37,10 @@ class Request { return wrappedFetch(url, options); } + async buffer(url, options = {}) { + return this.fetch(url, options).then(res => res.buffer()); + } + async text(url, options = {}) { return this.fetch(url, options).then(res => res.text()); }