-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: more helpful error when setting up project without lean/git (#407)
- Loading branch information
Showing
3 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { OutputChannel, Uri } from 'vscode'; | ||
import { ExecutionExitCode, ExecutionResult, batchExecute } from './batch'; | ||
|
||
export class SetupDiagnoser { | ||
channel: OutputChannel | ||
cwdUri: Uri | undefined | ||
|
||
constructor(channel: OutputChannel, cwdUri: Uri | undefined) { | ||
this.channel = channel | ||
this.cwdUri = cwdUri | ||
} | ||
|
||
async checkLakeAndDepsAvailable(): Promise<'Success' | 'LakeUnavailable' | 'GitUnavailable'> { | ||
if (!await this.checkLakeAvailable()) { | ||
return 'LakeUnavailable' | ||
} | ||
if (!await this.checkGitAvailable()) { | ||
return 'GitUnavailable' | ||
} | ||
return 'Success' | ||
} | ||
|
||
async checkLakeAvailable(): Promise<boolean> { | ||
const lakeVersionResult = await this.runSilently('lake', ['--version']) | ||
return lakeVersionResult.exitCode === ExecutionExitCode.Success | ||
} | ||
|
||
async checkGitAvailable(): Promise<boolean> { | ||
const gitVersionResult = await batchExecute('git', ['--version']) | ||
return gitVersionResult.exitCode === ExecutionExitCode.Success | ||
} | ||
|
||
private async runSilently(executablePath: string, args: string[]): Promise<ExecutionResult> { | ||
return batchExecute(executablePath, args, this.cwdUri?.fsPath, { combined: this.channel }) | ||
} | ||
} | ||
|
||
export function diagnose(channel: OutputChannel, cwdUri: Uri | undefined): SetupDiagnoser { | ||
return new SetupDiagnoser(channel, cwdUri) | ||
} | ||
|