( client: Client, path: string, projectName?: string, projectNameIsExplicit?: boolean )
| 76 | } |
| 77 | |
| 78 | export async function getProjectLink( |
| 79 | client: Client, |
| 80 | path: string, |
| 81 | projectName?: string, |
| 82 | projectNameIsExplicit?: boolean |
| 83 | ): Promise<ProjectLink | null> { |
| 84 | // Prefer an explicit per-directory link (`.vercel/project.json`) over a |
| 85 | // repository-level link (`.vercel/repo.json`). This prevents scenarios where |
| 86 | // a freshly-created local link (e.g. after `vc link`) is ignored and the |
| 87 | // user is re-prompted to select a repo-linked project again. |
| 88 | // When `projectNameIsExplicit` is true, the caller is resolving a user- |
| 89 | // supplied `--project` value, so mismatched local links must not win. |
| 90 | const dirLink = await getLinkFromDir(getVercelDirectory(path)); |
| 91 | if (dirLink) { |
| 92 | if (!projectNameIsExplicit || !projectName) { |
| 93 | return dirLink; |
| 94 | } |
| 95 | |
| 96 | if ( |
| 97 | dirLink.projectId === projectName || |
| 98 | dirLink.projectName === projectName |
| 99 | ) { |
| 100 | return dirLink; |
| 101 | } |
| 102 | } |
| 103 | return await getProjectLinkFromRepoLink( |
| 104 | client, |
| 105 | path, |
| 106 | projectName, |
| 107 | projectNameIsExplicit |
| 108 | ); |
| 109 | } |
| 110 | |
| 111 | async function getProjectLinkFromRepoLink( |
| 112 | client: Client, |
no test coverage detected