2017-07-30 20:58:31 +02:00

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
}]
}
}