(cmd, opt, cb)
| 1155 | }; |
| 1156 | }; |
| 1157 | var which = (cmd, opt, cb) => { |
| 1158 | if (typeof opt === "function") { |
| 1159 | cb = opt; |
| 1160 | opt = {}; |
| 1161 | } |
| 1162 | if (!opt) |
| 1163 | opt = {}; |
| 1164 | const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt); |
| 1165 | const found = []; |
| 1166 | const step = (i3) => new Promise((resolve, reject) => { |
| 1167 | if (i3 === pathEnv.length) |
| 1168 | return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd)); |
| 1169 | const ppRaw = pathEnv[i3]; |
| 1170 | const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw; |
| 1171 | const pCmd = path5.join(pathPart, cmd); |
| 1172 | const p4 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd; |
| 1173 | resolve(subStep(p4, i3, 0)); |
| 1174 | }); |
| 1175 | const subStep = (p4, i3, ii) => new Promise((resolve, reject) => { |
| 1176 | if (ii === pathExt.length) |
| 1177 | return resolve(step(i3 + 1)); |
| 1178 | const ext = pathExt[ii]; |
| 1179 | isexe(p4 + ext, { pathExt: pathExtExe }, (er2, is) => { |
| 1180 | if (!er2 && is) { |
| 1181 | if (opt.all) |
| 1182 | found.push(p4 + ext); |
| 1183 | else |
| 1184 | return resolve(p4 + ext); |
| 1185 | } |
| 1186 | return resolve(subStep(p4, i3, ii + 1)); |
| 1187 | }); |
| 1188 | }); |
| 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); |
nothing calls this directly
no test coverage detected
searching dependent graphs…