(
args: string[],
options: ExecVercelCliOptions = {}
)
| 35 | * caller passes a sanitized `PATH`. |
| 36 | */ |
| 37 | export async function execVercelCli( |
| 38 | args: string[], |
| 39 | options: ExecVercelCliOptions = {} |
| 40 | ): Promise<ExecVercelCliResult> { |
| 41 | const cwd = path.resolve(options.cwd ?? process.cwd()); |
| 42 | await assertValidCwd(cwd); |
| 43 | const env = mergeExecEnv(options.env); |
| 44 | const pathValue = getEnvPath(env); |
| 45 | |
| 46 | try { |
| 47 | return await execResolvedVercelCli(args, options, cwd, env, pathValue); |
| 48 | } catch (error) { |
| 49 | if ( |
| 50 | error instanceof VercelCliError && |
| 51 | error.code === 'VERCEL_CLI_NOT_FOUND' |
| 52 | ) { |
| 53 | clearCachedCliInvocation(cwd, pathValue); |
| 54 | return await execResolvedVercelCli(args, options, cwd, env, pathValue); |
| 55 | } |
| 56 | |
| 57 | throw error; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Resolves one CLI invocation and executes it once. |
no test coverage detected