MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / resolveInputPath

Function resolveInputPath

javascript/selenium-webdriver/generate_bidi.mjs:93–103  ·  view source on GitHub ↗

* Resolve a path that came from a Bazel $(location …) expansion. * * When a js_binary runs inside a js_run_binary action Bazel sets BAZEL_BINDIR * and the js_binary wrapper calls process.chdir(BAZEL_BINDIR) before handing * control to the script. $(location) values are relative to the *execroot*

(p)

Source from the content-addressed store, hash-verified

91 * Outside Bazel (BAZEL_BINDIR unset) paths are resolved normally.
92 */
93function resolveInputPath(p) {
94 if (!p) return null
95 if (!process.env.BAZEL_BINDIR) return resolve(p)
96 // Normalize both strings to forward slashes before prefix-stripping so that
97 // mixed separators on Windows (BAZEL_BINDIR uses '\', $(location) uses '/')
98 // do not cause the startsWith check to silently fail.
99 const normalizedP = p.replaceAll('\\', '/')
100 const normalizedBindir = process.env.BAZEL_BINDIR.replaceAll('\\', '/')
101 const prefix = normalizedBindir + '/'
102 return resolve(normalizedP.startsWith(prefix) ? normalizedP.slice(prefix.length) : normalizedP)
103}
104
105// ============================================================
106// Main

Callers 2

parseCddlFunction · 0.85
readJsonFunction · 0.85

Calls 1

resolveFunction · 0.50

Tested by

no test coverage detected