* 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)
| 3516 | * @returns Promise<string> path to tool |
| 3517 | */ |
| 3518 | function 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 | } |
| 3543 | exports.which = which; |
| 3544 | /** |
| 3545 | * Returns a list of all occurrences of the given tool on the system path. |
no test coverage detected
searching dependent graphs…