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

Predicate tryExtensions

Gets a file in folder dir whose name is of the form basename.extension, where extension has the given priority.

This may resolve to an mjs file even though require will never find those files at runtime. We do this to handle the case where an mjs file is transpiled to js, and we want to find the original source file.

Import path

import semmle.javascript.NodeModuleResolutionImpl
File tryExtensions(Folder dir, string basename, int priority)