|
1 | | -"use strict"; |
| 1 | +import * as path from "node:path"; |
| 2 | +import * as fs from "node:fs/promises"; |
2 | 3 |
|
3 | 4 | if (process.env.NO_UPDATE) { |
4 | 5 | process.exit(0); |
5 | 6 | } |
6 | 7 |
|
7 | | -const path = require("node:path"); |
8 | | -const fs = require("node:fs/promises"); |
9 | | - |
10 | 8 | // Pin to specific version, reflecting the spec version in the readme. |
11 | 9 | // |
12 | 10 | // To get the latest commit: |
13 | 11 | // 1. Go to https://github.com/web-platform-tests/wpt/tree/master/fetch/data-urls |
14 | 12 | // 2. Press "y" on your keyboard to get a permalink |
15 | 13 | // 3. Copy the commit hash |
16 | | -const commitHash = "d9d78543960a04ea8ad8f1aa3c7536b6a9a87d9a"; |
| 14 | +const commitHash = "2dc0ad4f330f0b5647d11b00ae7437b668cb8df3"; |
17 | 15 |
|
18 | 16 | const urlPrefix = `https://raw.githubusercontent.com/w3c/web-platform-tests/${commitHash}` + |
19 | 17 | `/fetch/data-urls/resources/`; |
20 | 18 |
|
21 | 19 | const files = ["base64.json", "data-urls.json"]; |
22 | 20 |
|
23 | | -async function main() { |
24 | | - await Promise.all(files.map(async file => { |
25 | | - const url = urlPrefix + file; |
26 | | - const targetFile = path.resolve(__dirname, "..", "test", "web-platform-tests", file); |
27 | | - |
28 | | - const res = await fetch(url); |
29 | | - await fs.writeFile(targetFile, res.body); |
30 | | - })); |
31 | | -} |
| 21 | +await Promise.all(files.map(async file => { |
| 22 | + const url = urlPrefix + file; |
| 23 | + const targetFile = path.resolve(import.meta.dirname, "..", "test", "web-platform-tests", file); |
32 | 24 |
|
33 | | -main().catch(e => { |
34 | | - console.error(e.stack); |
35 | | - process.exit(1); |
36 | | -}); |
| 25 | + const res = await fetch(url); |
| 26 | + await fs.writeFile(targetFile, res.body); |
| 27 | +})); |
0 commit comments