mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-20 03:20:12 +00:00
32 lines
736 B
TypeScript
32 lines
736 B
TypeScript
import * as fs from 'mz/fs'
|
|
import { Injectable } from '@angular/core'
|
|
import { HostAppService, Platform } from 'terminus-core'
|
|
|
|
import { ShellProvider, IShell } from '../api'
|
|
|
|
@Injectable()
|
|
export class WSLShellProvider extends ShellProvider {
|
|
constructor (
|
|
private hostApp: HostAppService,
|
|
) {
|
|
super()
|
|
}
|
|
|
|
async provide (): Promise<IShell[]> {
|
|
if (this.hostApp.platform !== Platform.Windows) {
|
|
return []
|
|
}
|
|
|
|
const wslPath = `${process.env.windir}\\system32\\bash.exe`
|
|
if (!await fs.exists(wslPath)) {
|
|
return []
|
|
}
|
|
|
|
return [{
|
|
id: 'wsl',
|
|
name: 'Bash on Windows',
|
|
command: wslPath
|
|
}]
|
|
}
|
|
}
|