CodeQL library for JavaScript
codeql/javascript-all 0.7.5 ( changelog , source )
Search

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:

nodeModulesdistance
/a/node_modules/b/node_modules0
/a/node_modules2
/node_modules3

Import path

import javascript
predicate findNodeModulesFolder ( Folder f , Folder nodeModules , int distance )