Skip to content

Commit

Permalink
chore(test): add script update-all-data.js
Browse files Browse the repository at this point in the history
  • Loading branch information
styfle committed Oct 29, 2024
1 parent e7f8984 commit 2dcf0db
Show file tree
Hide file tree
Showing 2 changed files with 15 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.js
```
14 changes: 14 additions & 0 deletions test/ecmascript/update-all-data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { readdir, writeFile } = require('fs/promises');
const { join } = require('path');

async function main() {
const files = await readdir(__dirname);
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(join(__dirname, file), text);
}
}

main().then(() => console.log('Done.')).catch(e => console.error(e));

0 comments on commit 2dcf0db

Please sign in to comment.