From 76bbd3fdee976c08cfed58fdfab3ec43b6d6a3c4 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Mon, 11 Mar 2024 16:20:04 +0200 Subject: [PATCH] unicorn/prefer-top-level-await --- .eslintrc.json | 3 +-- build/build-plugins.mjs | 19 ++++++----------- build/change-version.mjs | 46 +++++++++++++++++----------------------- 3 files changed, 26 insertions(+), 42 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 081b456514..8908fc91c4 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -112,8 +112,7 @@ "sourceType": "module" }, "rules": { - "no-console": "off", - "unicorn/prefer-top-level-await": "off" + "no-console": "off" } }, { diff --git a/build/build-plugins.mjs b/build/build-plugins.mjs index 252b4b4b0a..addd59dafb 100644 --- a/build/build-plugins.mjs +++ b/build/build-plugins.mjs @@ -87,19 +87,12 @@ const build = async plugin => { console.log(`Built ${plugin.className}`) } -(async () => { - try { - const basename = path.basename(__filename) - const timeLabel = `[${basename}] finished` +const basename = path.basename(__filename) +const timeLabel = `[${basename}] finished` - console.log('Building individual plugins...') - console.time(timeLabel) +console.log('Building individual plugins...') +console.time(timeLabel) - await Promise.all(Object.values(resolvedPlugins).map(plugin => build(plugin))) +await Promise.all(Object.values(resolvedPlugins).map(plugin => build(plugin))) - console.timeEnd(timeLabel) - } catch (error) { - console.error(error) - process.exit(1) - } -})() +console.timeEnd(timeLabel) diff --git a/build/change-version.mjs b/build/change-version.mjs index 30cfcc4561..1b1a597afa 100644 --- a/build/change-version.mjs +++ b/build/change-version.mjs @@ -81,33 +81,25 @@ function showUsage(args) { process.exit(1) } -async function main(args) { - let [oldVersion, newVersion] = args +const args = process.argv.slice(2) +let [oldVersion, newVersion] = args - if (!oldVersion || !newVersion) { - showUsage(args) - } - - // Strip any leading `v` from arguments because - // otherwise we will end up with duplicate `v`s - [oldVersion, newVersion] = [oldVersion, newVersion].map(arg => { - return arg.startsWith('v') ? arg.slice(1) : arg - }) - - if (oldVersion === newVersion) { - showUsage(args) - } - - bumpNpmVersion(newVersion) - - try { - await Promise.all( - FILES.map(file => replaceRecursively(file, oldVersion, newVersion)) - ) - } catch (error) { - console.error(error) - process.exit(1) - } +if (!oldVersion || !newVersion) { + showUsage(args) } -main(process.argv.slice(2)) +// Strip any leading `v` from arguments because +// otherwise we will end up with duplicate `v`s +[oldVersion, newVersion] = [oldVersion, newVersion].map(arg => { + return arg.startsWith('v') ? arg.slice(1) : arg +}) + +if (oldVersion === newVersion) { + showUsage(args) +} + +bumpNpmVersion(newVersion) + +await Promise.all( + FILES.map(file => replaceRecursively(file, oldVersion, newVersion)) +)