Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ async function execWindowsCmdAsync(command: string): Promise<{ stdout: string; s
});
}

async function isWslAvailable(): Promise<boolean> {
try {
const { stdout } = await execWindowsCmdAsync('wsl -l -q');
return stdout.trim().length > 0;
} catch {
return false;
}
}
Comment thread
Variiuz marked this conversation as resolved.

export class Cli {
private static cliInstance: CodacyCli | null = null;

Expand Down Expand Up @@ -67,9 +76,7 @@ export class Cli {
Cli.cliInstance = new LinuxCodacyCli(rootPath, provider, organization, repository);
} else if (platform === 'win32') {
// is WSL installed?
const { stdout } = await execWindowsCmdAsync('wsl --status');
const hasWSL = stdout.includes('Default Distribution');

const hasWSL = await isWslAvailable();
Cli.cliInstance = hasWSL
? new WinWSLCodacyCli(rootPath, provider, organization, repository)
: new WinCodacyCli(rootPath, provider, organization, repository);
Expand Down