Predicate findNodeModulesFolder
Holds if nodeModules
is a folder of the form <prefix>/node_modules
, where
<prefix>
is a (not necessarily proper) prefix of f
and does not end in /node_modules
,
and distance
is the number of path elements of f
that are missing from <prefix>
.
This predicate implements the NODE_MODULES_PATHS
procedure from the
specification of require.resolve
.
For example, if f
is /a/node_modules/b
, we get the following results:
nodeModules | distance |
---|---|
/a/node_modules/b/node_modules | 0 |
/a/node_modules | 2 |
/node_modules | 3 |
Import path
import javascript
predicate findNodeModulesFolder(Folder f, Folder nodeModules, int distance)