({ data, alreadyConfigured }: TutorialConfigParams)
| 12 | } |
| 13 | |
| 14 | const tutorialConfig = async ({ data, alreadyConfigured }: TutorialConfigParams): Promise<E.ErrorMessage | void> => { |
| 15 | if (!alreadyConfigured) { |
| 16 | // setup git, add remote |
| 17 | const initError: E.ErrorMessage | void = await git.initIfNotExists().catch( |
| 18 | (error: Error): E.ErrorMessage => ({ |
| 19 | type: 'GitNotFound', |
| 20 | message: error.message, |
| 21 | actions: [{ label: 'Retry', transition: 'TRY_AGAIN' }], |
| 22 | }), |
| 23 | ) |
| 24 | |
| 25 | if (initError) { |
| 26 | return initError |
| 27 | } |
| 28 | |
| 29 | // verify that internet is connected, remote exists and branch exists |
| 30 | const remoteConnectError: E.ErrorMessage | void = await git.checkRemoteConnects(data.config.repo).catch( |
| 31 | (error: Error): E.ErrorMessage => ({ |
| 32 | type: 'FailedToConnectToGitRepo', |
| 33 | message: error.message, |
| 34 | actions: [{ label: 'Retry', transition: 'TRY_AGAIN' }], |
| 35 | }), |
| 36 | ) |
| 37 | |
| 38 | if (remoteConnectError) { |
| 39 | return remoteConnectError |
| 40 | } |
| 41 | |
| 42 | // TODO if remote not already set |
| 43 | const coderoadRemoteError: E.ErrorMessage | void = await git.setupCodeRoadRemote(data.config.repo.uri).catch( |
| 44 | (error: Error): E.ErrorMessage => ({ |
| 45 | type: 'GitRemoteAlreadyExists', |
| 46 | message: error.message, |
| 47 | }), |
| 48 | ) |
| 49 | |
| 50 | if (coderoadRemoteError) { |
| 51 | return coderoadRemoteError |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | await vscode.commands.executeCommand(COMMANDS.CONFIG_TEST_RUNNER, { data, alreadyConfigured }) |
| 56 | |
| 57 | if (!DISABLE_RUN_ON_SAVE) { |
| 58 | // verify if file test should run based on document saved |
| 59 | const shouldRunTest = (document: vscode.TextDocument): boolean => { |
| 60 | // must be a file |
| 61 | if (document.uri.scheme !== 'file') { |
| 62 | return false |
| 63 | } |
| 64 | return true |
| 65 | } |
| 66 | |
| 67 | // setup onSave hook |
| 68 | vscode.workspace.onDidSaveTextDocument((document: vscode.TextDocument) => { |
| 69 | if (shouldRunTest(document)) { |
| 70 | vscode.commands.executeCommand(COMMANDS.RUN_TEST) |
| 71 | } |
no test coverage detected