wsl.ts 807 字节
Newer Older
E
Eugene Pankov 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
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',
28 29 30 31
            command: wslPath,
            env: {
                TERM: 'xterm-color',
            }
E
Eugene Pankov 已提交
32 33 34
        }]
    }
}