-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathfind-up.node.txt
53 lines (44 loc) · 2.96 KB
/
find-up.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
┏━━━━━━━━━━━━━┓
┃ FIND-UP ┃
┗━━━━━━━━━━━━━┛
┌─────────────┐
│ FIND-UP │
└─────────────┘
ALTERNATIVE ==> # - find-up (preferred):
# - can return multiple matching, instead of first matching
# - custom cwd
# - stop|limit recursion
# - look only for either directory or regular file
# - [no-]follow symlinks
# - escalade (preferred if need small):
# - 3x faster
# - 3x smaller
# - can execute logic on each parent directory
VERSION ==> #6.3.0
findUpMultiple[Sync](FILE[, OPTS])#Looks for FILE in current directory, then up recursively.
->[PROMISE_]'PATH'_ARR #Returns all matching 'PATH' (empty ARR if none)
#FILE can be:
# - 'PATH'[_ARR]
# - FUNC('DIR')->VAL where VAL can be:
# - [PROMISE_]'PATH'
# - undefined: no match
# - findUpStop:
# - stop iteration
# - fired on each 'DIR'
#OPTS:
# - cwd 'PATH'|URL (def: process.cwd())
# - stopAt 'DIR'|URL (def: root)
# - limit NUM (def: Infinity):
# - maximum amount of 'PATH' to return
# - only return at most one 'PATH' per directory
# - any OPTS from LOCATE-PATH (see its doc)
findUp[Sync](...)
->[PROMISE_]'PATH' #Same as findUpMultiple[Sync](...) but returning the first matching 'PATH', or undefined if none.
┌─────────────┐
│ PKG-DIR │
└─────────────┘
ALTERNATIVES ==> # - `node:module` findPackageJSON() (preferred with Node >=23.2.0)
# - pkg-dir (preferred otherwise)
VERSION ==> #8.0.0
packageDirectory[Sync](OPTS)
[->[PROMISE_]'DIR'] #Uses FIND-UP for package.json, i.e. returns package root directory (LPREFIX)