* Resolves the CLI invocation from local bins first, then the provided PATH.
( cwd: string, pathValue: string )
| 177 | * Resolves the CLI invocation from local bins first, then the provided PATH. |
| 178 | */ |
| 179 | async function resolveCliInvocation( |
| 180 | cwd: string, |
| 181 | pathValue: string |
| 182 | ): Promise<VercelCliResolution> { |
| 183 | const localBinSearch = await getLocalBinSearch(cwd); |
| 184 | const diagnostics: ResolutionDiagnostics = { |
| 185 | localBinSearch: localBinSearch.diagnostics, |
| 186 | skippedLocalBins: [], |
| 187 | }; |
| 188 | const resolvedPath = prependPathEntries( |
| 189 | pathValue, |
| 190 | localBinSearch.directories |
| 191 | ); |
| 192 | |
| 193 | for (const command of getVercelCommandNames()) { |
| 194 | const resolvedCommand = await findCommandInPath( |
| 195 | command, |
| 196 | resolvedPath, |
| 197 | cwd, |
| 198 | localBinSearch, |
| 199 | diagnostics |
| 200 | ); |
| 201 | if (!resolvedCommand) { |
| 202 | continue; |
| 203 | } |
| 204 | |
| 205 | if (isNodeScript(resolvedCommand.realPath)) { |
| 206 | return { |
| 207 | found: true, |
| 208 | command: process.execPath, |
| 209 | commandArgs: [resolvedCommand.realPath], |
| 210 | source: resolvedCommand.source, |
| 211 | diagnostics, |
| 212 | }; |
| 213 | } |
| 214 | |
| 215 | return { |
| 216 | found: true, |
| 217 | command: resolvedCommand.realPath, |
| 218 | commandArgs: [], |
| 219 | source: resolvedCommand.source, |
| 220 | diagnostics, |
| 221 | }; |
| 222 | } |
| 223 | |
| 224 | return { found: false, diagnostics }; |
| 225 | } |
| 226 | |
| 227 | /** |
| 228 | * Resolves the first usable command from PATH, validating local bins specially. |
no test coverage detected