Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wpt): download files as buffer instead of text #535

Merged
merged 1 commit into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/github/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion lib/wpt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class WPTUpdater {
// If filepath starts with '/', the path is relative to WPT project root,
// otherwise it's relative to the path of this updater
async pullTextFile(dest, filepath) {
const content = await this.tree.text(filepath);
const content = await this.tree.buffer(filepath);
const filename = path.join(dest, filepath);
writeFile(filename, content);
this.cli.updateSpinner(`Downloaded ${filename}`);
Expand Down