File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
dev-packages/test-utils/src Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,20 @@ import { spawn } from 'child_process';
55import * as fs from 'fs' ;
66import * as path from 'path' ;
77import * as readline from 'readline' ;
8+ import { fileURLToPath } from 'url' ;
9+
10+ /**
11+ * Get the directory name, works in both CJS and ESM environments.
12+ */
13+ function getDirname ( ) : string {
14+ // ESM environment
15+ if ( typeof import . meta !== 'undefined' && import . meta. url ) {
16+ return path . dirname ( fileURLToPath ( import . meta. url ) ) ;
17+ }
18+ // CJS environment
19+ // eslint-disable-next-line no-restricted-globals
20+ return __dirname ;
21+ }
822
923/**
1024 * Find the monorepo root by looking for a package.json with workspaces.
@@ -30,7 +44,7 @@ function findRepoRoot(startDir: string): string {
3044}
3145
3246// Find spotlight binary in repo root's node_modules
33- const REPO_ROOT = findRepoRoot ( __dirname ) ;
47+ const REPO_ROOT = findRepoRoot ( getDirname ( ) ) ;
3448const SPOTLIGHT_BIN = path . join ( REPO_ROOT , 'node_modules' , '.bin' , 'spotlight' ) ;
3549
3650interface SpotlightOptions {
You can’t perform that action at this time.
0 commit comments