Skip to content

Commit

Permalink
Chore: get rid of esm __dirname workaroud in favor of now stable impo…
Browse files Browse the repository at this point in the history
…rt.meta.dirname
  • Loading branch information
SBoudrias committed Mar 26, 2024
1 parent 353f022 commit 73b4ba5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
6 changes: 1 addition & 5 deletions packages/inquirer/examples/spawn.js
Original file line number Diff line number Diff line change
@@ -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',
});
5 changes: 1 addition & 4 deletions tools/setup-packages.mjs
Original file line number Diff line number Diff line change
@@ -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');
}
Expand All @@ -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) => {
Expand Down

0 comments on commit 73b4ba5

Please sign in to comment.