MCPcopy
hub / github.com/di-sukharev/opencommit / whichSync

Function whichSync

out/cli.cjs:1191–1219  ·  view source on GitHub ↗
(cmd, opt)

Source from the content-addressed store, hash-verified

1189 return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
1190 };
1191 var whichSync = (cmd, opt) => {
1192 opt = opt || {};
1193 const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
1194 const found = [];
1195 for (let i3 = 0; i3 < pathEnv.length; i3++) {
1196 const ppRaw = pathEnv[i3];
1197 const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
1198 const pCmd = path5.join(pathPart, cmd);
1199 const p4 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
1200 for (let j4 = 0; j4 < pathExt.length; j4++) {
1201 const cur = p4 + pathExt[j4];
1202 try {
1203 const is = isexe.sync(cur, { pathExt: pathExtExe });
1204 if (is) {
1205 if (opt.all)
1206 found.push(cur);
1207 else
1208 return cur;
1209 }
1210 } catch (ex) {
1211 }
1212 }
1213 }
1214 if (opt.all && found.length)
1215 return found;
1216 if (opt.nothrow)
1217 return null;
1218 throw getNotFoundError(cmd);
1219 };
1220 module2.exports = which;
1221 which.sync = whichSync;
1222 }

Callers

nothing calls this directly

Calls 5

getPathInfoFunction · 0.85
getNotFoundErrorFunction · 0.85
testMethod · 0.80
sliceMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…