Skip to content

Commit

Permalink
chore(test): add script update-all-data.mjs (#449)
Browse files Browse the repository at this point in the history
This script is a little bit easier to run and doesn't rely on the user
having `curl` installed.

It also updates files based on the `data-` prefix so it will be easier
to keep in sync when adding more.

---------

Co-authored-by: Nathan Rajlich <[email protected]>
  • Loading branch information
styfle and TooTallNate authored Oct 29, 2024
1 parent e7f8984 commit 2471f2f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 1 addition & 6 deletions test/ecmascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,5 @@ In our case, we only need to test parsing and not actually execute the tests.
You can run the following script from this directory to update this test suite.

```sh
curl -L -o data-common.json https://raw.githubusercontent.com/kangax/compat-table/gh-pages/data-common.json
curl -L -o data-es5.js https://raw.githubusercontent.com/kangax/compat-table/gh-pages/data-es5.js
curl -L -o data-es6.js https://raw.githubusercontent.com/kangax/compat-table/gh-pages/data-es6.js
curl -L -o data-es2016plus.js https://raw.githubusercontent.com/kangax/compat-table/gh-pages/data-es2016plus.js
curl -L -o data-esintl.js https://raw.githubusercontent.com/kangax/compat-table/gh-pages/data-esintl.js
curl -L -o data-esnext.js https://raw.githubusercontent.com/kangax/compat-table/gh-pages/data-esnext.js
node update-all-data.mjs
```
13 changes: 13 additions & 0 deletions test/ecmascript/update-all-data.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { readdir, writeFile } from 'fs/promises';

const dir = new URL('./', import.meta.url);
const files = await readdir(dir);

for (const file of files.filter(f => f.startsWith('data-'))) {
const url = `https://raw.githubusercontent.com/kangax/compat-table/gh-pages/${file}`;
const res = await fetch(url);
const text = await res.text();
await writeFile(new URL(file, dir), text);
}

console.log('Update complete!')

0 comments on commit 2471f2f

Please sign in to comment.