MCPcopy Create free account
hub / github.com/mysticatea/eslint-plugin-node / simulateNodeResolutionAlgorithm

Function simulateNodeResolutionAlgorithm

lib/rules/shebang.js:15–22  ·  view source on GitHub ↗
(filePath, binField)

Source from the content-addressed store, hash-verified

13const NODE_SHEBANG_PATTERN = /#!\/usr\/bin\/env node(?: [^\r\n]+?)?\n/u
14
15function simulateNodeResolutionAlgorithm(filePath, binField) {
16 const possibilities = [filePath]
17 let newFilePath = filePath.replace(/\.js$/u, "")
18 possibilities.push(newFilePath)
19 newFilePath = newFilePath.replace(/[/\\]index$/u, "")
20 possibilities.push(newFilePath)
21 return possibilities.includes(binField)
22}
23
24/**
25 * Checks whether or not a given path is a `bin` file.

Callers 1

isBinFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…