1
1
import { homedir as getHomeDir } from 'os'
2
- import { normalize , dirname } from 'path'
2
+ import { dirname } from 'path'
3
3
import { env } from 'process'
4
- import { fileURLToPath } from 'url'
5
4
6
5
// Retrieve list of directories to search:
7
6
// - current directory
8
7
// - any parent directory
9
8
// - home directory
10
9
// If `global` option is `true`, only home directory is searched
11
- export const getSearchDirs = function ( { cwd, globalOpt } ) {
10
+ export const getSearchDirs = function ( cwd , globalOpt ) {
12
11
// For tests only
13
12
const homeDir = env . TEST_HOME_DIR === undefined ? HOME_DIR : env . TEST_HOME_DIR
14
13
15
14
if ( globalOpt ) {
16
15
return [ homeDir ]
17
16
}
18
17
19
- const cwdA = normalizeCwd ( cwd )
20
- const parentDirs = getParentDirs ( cwdA )
18
+ const parentDirs = getParentDirs ( cwd )
21
19
22
20
if ( parentDirs . includes ( homeDir ) ) {
23
21
return parentDirs
@@ -26,10 +24,6 @@ export const getSearchDirs = function ({ cwd, globalOpt }) {
26
24
return [ ...parentDirs , homeDir ]
27
25
}
28
26
29
- const normalizeCwd = function ( cwd ) {
30
- return cwd instanceof URL ? fileURLToPath ( cwd ) : normalize ( cwd )
31
- }
32
-
33
27
const getParentDirs = function ( dir ) {
34
28
const parentDir = dirname ( dir )
35
29
const parentDirs = parentDir === dir ? [ ] : getParentDirs ( parentDir )
0 commit comments