From 73b4ba5a22cefa773c6d6dd4a595bbe47f24b772 Mon Sep 17 00:00:00 2001 From: Simon Boudrias Date: Tue, 26 Mar 2024 11:59:20 -0400 Subject: [PATCH] Chore: get rid of esm __dirname workaroud in favor of now stable import.meta.dirname --- packages/inquirer/examples/spawn.js | 6 +----- tools/setup-packages.mjs | 5 +---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/inquirer/examples/spawn.js b/packages/inquirer/examples/spawn.js index 64c6a3452..fcfe06476 100644 --- a/packages/inquirer/examples/spawn.js +++ b/packages/inquirer/examples/spawn.js @@ -1,10 +1,6 @@ import { spawn } from 'node:child_process'; -import { dirname } from 'node:path'; -import { fileURLToPath } from 'node:url'; - -const __dirname = dirname(fileURLToPath(import.meta.url)); spawn('node', ['input.js'], { - cwd: __dirname, + cwd: import.meta.dirname, stdio: 'inherit', }); diff --git a/tools/setup-packages.mjs b/tools/setup-packages.mjs index 2fdc680db..caac03e19 100644 --- a/tools/setup-packages.mjs +++ b/tools/setup-packages.mjs @@ -1,11 +1,8 @@ import path from 'node:path'; import fs from 'node:fs/promises'; -import url from 'node:url'; import { globby } from 'globby'; import prettier from 'prettier'; -const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); - function readFile(filepath) { return fs.readFile(filepath, 'utf-8'); } @@ -27,7 +24,7 @@ async function writeFile(filepath, content) { } } -const rootPkg = await readJSONFile(path.join(__dirname, '../package.json')); +const rootPkg = await readJSONFile(path.join(import.meta.dirname, '../package.json')); const paths = await globby(['packages/**/package.json', '!**/node_modules']); paths.forEach(async (pkgPath) => {