MCPcopy Create free account
hub / github.com/Azure/powershell / which

Function which

lib/index.js:3518–3542  ·  view source on GitHub ↗

* Returns path of a tool had the tool actually been invoked. Resolves via paths. * If you check and the tool does not exist, it will throw. * * @param tool name of the tool * @param check whether to check if tool exists * @returns Promise path to to

(tool, check)

Source from the content-addressed store, hash-verified

3516 * @returns Promise<string> path to tool
3517 */
3518function which(tool, check) {
3519 return __awaiter(this, void 0, void 0, function* () {
3520 if (!tool) {
3521 throw new Error("parameter 'tool' is required");
3522 }
3523 // recursive when check=true
3524 if (check) {
3525 const result = yield which(tool, false);
3526 if (!result) {
3527 if (ioUtil.IS_WINDOWS) {
3528 throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`);
3529 }
3530 else {
3531 throw new Error(`Unable to locate executable file: ${tool}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`);
3532 }
3533 }
3534 return result;
3535 }
3536 const matches = yield findInPath(tool);
3537 if (matches && matches.length > 0) {
3538 return matches[0];
3539 }
3540 return '';
3541 });
3542}
3543exports.which = which;
3544/**
3545 * Returns a list of all occurrences of the given tool on the system path.

Callers 1

unzipUsing7ZipMethod · 0.85

Calls 1

findInPathFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…