MCPcopy Create free account
hub / github.com/angular/dev-infra / findInPath

Function findInPath

github-actions/browserstack/set-browserstack-env.js:20006–20046  ·  view source on GitHub ↗
(tool)

Source from the content-addressed store, hash-verified

20004 });
20005 }
20006 function findInPath(tool) {
20007 return __awaiter3(this, void 0, void 0, function* () {
20008 if (!tool) {
20009 throw new Error("parameter 'tool' is required");
20010 }
20011 const extensions = [];
20012 if (IS_WINDOWS && process.env["PATHEXT"]) {
20013 for (const extension of process.env["PATHEXT"].split(path2.delimiter)) {
20014 if (extension) {
20015 extensions.push(extension);
20016 }
20017 }
20018 }
20019 if (isRooted(tool)) {
20020 const filePath = yield tryGetExecutablePath(tool, extensions);
20021 if (filePath) {
20022 return [filePath];
20023 }
20024 return [];
20025 }
20026 if (tool.includes(path2.sep)) {
20027 return [];
20028 }
20029 const directories = [];
20030 if (process.env.PATH) {
20031 for (const p of process.env.PATH.split(path2.delimiter)) {
20032 if (p) {
20033 directories.push(p);
20034 }
20035 }
20036 }
20037 const matches = [];
20038 for (const directory of directories) {
20039 const filePath = yield tryGetExecutablePath(path2.join(directory, tool), extensions);
20040 if (filePath) {
20041 matches.push(filePath);
20042 }
20043 }
20044 return matches;
20045 });
20046 }
20047
20048 //
20049 var import_timers = __require("timers");

Callers 1

whichFunction · 0.70

Calls 4

__awaiter3Function · 0.70
isRootedFunction · 0.70
tryGetExecutablePathFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected