| 103 | } |
| 104 | |
| 105 | export async function checkRemoteConnects(repo: TT.TutorialRepo): Promise<never | void> { |
| 106 | // check for git repo |
| 107 | const externalRepoExists = await exec({ command: `git ls-remote --exit-code --heads ${repo.uri}` }) |
| 108 | if (externalRepoExists.stderr) { |
| 109 | // no repo found or no internet connection |
| 110 | throw new Error(externalRepoExists.stderr) |
| 111 | } |
| 112 | // check for git repo branch |
| 113 | const { stderr, stdout } = await exec({ command: `git ls-remote --exit-code --heads ${repo.uri} ${repo.branch}` }) |
| 114 | if (stderr) { |
| 115 | throw new Error(stderr) |
| 116 | } |
| 117 | if (!stdout || !stdout.length) { |
| 118 | throw new Error('Tutorial branch does not exist') |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | export async function addRemote(repo: string): Promise<never | void> { |
| 123 | const { stderr } = await exec({ command: `git remote add ${gitOrigin} ${repo} && git fetch ${gitOrigin}` }) |