From 8032a657eae8b58c6e77ba8d11406edbafe10409 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 29 Oct 2024 14:32:40 -0400 Subject: [PATCH] cjs => mjs --- test/ecmascript/README.md | 2 +- test/ecmascript/update-all-data.js | 14 -------------- test/ecmascript/update-all-data.mjs | 15 +++++++++++++++ 3 files changed, 16 insertions(+), 15 deletions(-) delete mode 100644 test/ecmascript/update-all-data.js create mode 100644 test/ecmascript/update-all-data.mjs diff --git a/test/ecmascript/README.md b/test/ecmascript/README.md index 785a090a..6be488fc 100644 --- a/test/ecmascript/README.md +++ b/test/ecmascript/README.md @@ -9,5 +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 -node update-all-data.js +node update-all-data.mjs ``` \ No newline at end of file diff --git a/test/ecmascript/update-all-data.js b/test/ecmascript/update-all-data.js deleted file mode 100644 index 5fa0ffcb..00000000 --- a/test/ecmascript/update-all-data.js +++ /dev/null @@ -1,14 +0,0 @@ -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)); diff --git a/test/ecmascript/update-all-data.mjs b/test/ecmascript/update-all-data.mjs new file mode 100644 index 00000000..9465c4a7 --- /dev/null +++ b/test/ecmascript/update-all-data.mjs @@ -0,0 +1,15 @@ +import { readdir, writeFile } from 'fs/promises'; +import { dirname, join } from 'path'; +import { fileURLToPath } from 'url'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +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); +} +console.log('Update complete!')