* Exec a tool. * Output will be streamed to the live console. * Returns promise with return code * * @param tool path to tool to exec * @param options optional exec options. See ExecOptions * @returns number
()
| 20283 | if (!p) { |
| 20284 | throw new Error('isRooted() parameter "p" cannot be empty'); |
| 20285 | } |
| 20286 | if (IS_WINDOWS) { |
| 20287 | return p.startsWith("\\") || /^[A-Z]:/i.test(p); |
| 20288 | } |
| 20289 | return p.startsWith("/"); |
| 20290 | } |
| 20291 | function tryGetExecutablePath(filePath, extensions) { |
| 20292 | return __awaiter2(this, void 0, void 0, function* () { |
| 20293 | let stats = void 0; |
| 20294 | try { |
| 20295 | stats = yield stat(filePath); |
| 20296 | } catch (err) { |
| 20297 | if (err.code !== "ENOENT") { |
| 20298 | console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); |
| 20299 | } |
| 20300 | } |
| 20301 | if (stats && stats.isFile()) { |
| 20302 | if (IS_WINDOWS) { |
| 20303 | const upperExt = path.extname(filePath).toUpperCase(); |
| 20304 | if (extensions.some((validExt) => validExt.toUpperCase() === upperExt)) { |
| 20305 | return filePath; |
| 20306 | } |
| 20307 | } else { |
| 20308 | if (isUnixExecutable(stats)) { |
| 20309 | return filePath; |
| 20310 | } |
| 20311 | } |
| 20312 | } |
| 20313 | const originalFilePath = filePath; |
| 20314 | for (const extension of extensions) { |
| 20315 | filePath = originalFilePath + extension; |
| 20316 | stats = void 0; |
| 20317 | try { |
| 20318 | stats = yield stat(filePath); |
| 20319 | } catch (err) { |
| 20320 | if (err.code !== "ENOENT") { |
| 20321 | console.log(`Unexpected error attempting to determine if executable file exists '${filePath}': ${err}`); |
| 20322 | } |
| 20323 | } |
| 20324 | if (stats && stats.isFile()) { |
| 20325 | if (IS_WINDOWS) { |
| 20326 | try { |
| 20327 | const directory = path.dirname(filePath); |
| 20328 | const upperName = path.basename(filePath).toUpperCase(); |
| 20329 | for (const actualName of yield readdir(directory)) { |
| 20330 | if (upperName === actualName.toUpperCase()) { |
| 20331 | filePath = path.join(directory, actualName); |
| 20332 | break; |
| 20333 | } |
| 20334 | } |
| 20335 | } catch (err) { |
| 20336 | console.log(`Unexpected error attempting to determine the actual case of the file '${filePath}': ${err}`); |
| 20337 | } |
| 20338 | return filePath; |
| 20339 | } else { |
| 20340 | if (isUnixExecutable(stats)) { |
| 20341 | return filePath; |
| 20342 | } |
no test coverage detected