MCPcopy
hub / github.com/SeleniumHQ/selenium / findInPath

Function findInPath

javascript/selenium-webdriver/io/index.js:210–229  ·  view source on GitHub ↗

* Searches the PATH environment variable for the given file. * @param {string} file The file to locate on the PATH. * @param {boolean=} opt_checkCwd Whether to always start with the search with * the current working directory, regardless of whether it is explicitly * listed on th

(file, opt_checkCwd)

Source from the content-addressed store, hash-verified

208 * not be found.
209 */
210function findInPath(file, opt_checkCwd) {
211 const dirs = []
212 if (opt_checkCwd) {
213 dirs.push(process.cwd())
214 }
215 dirs.push.apply(dirs, process.env['PATH'].split(path.delimiter))
216
217 let foundInDir = dirs.find((dir) => {
218 let tmp = path.join(dir, file)
219 try {
220 let stats = fs.statSync(tmp)
221 return stats.isFile() && !stats.isDirectory()
222 /*eslint no-unused-vars: "off"*/
223 } catch (ex) {
224 return false
225 }
226 })
227
228 return foundInDir ? path.join(foundInDir, file) : null
229}
230
231/**
232 * Reads the contents of the given file.

Callers

nothing calls this directly

Calls 6

splitMethod · 0.80
findMethod · 0.80
joinMethod · 0.80
isDirectoryMethod · 0.65
applyMethod · 0.45
isFileMethod · 0.45

Tested by

no test coverage detected