mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-19 10:59:54 +00:00
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { Injectable } from '@angular/core'
|
|
import { HostAppService, Platform } from 'terminus-core'
|
|
import { ShellProvider } from '../api/shellProvider'
|
|
import { Shell } from '../api/interfaces'
|
|
|
|
/* eslint-disable block-scoped-var */
|
|
|
|
try {
|
|
var wnr = require('windows-native-registry') // eslint-disable-line @typescript-eslint/no-var-requires, no-var
|
|
} catch { }
|
|
|
|
/** @hidden */
|
|
@Injectable()
|
|
export class PowerShellCoreShellProvider extends ShellProvider {
|
|
constructor (
|
|
private hostApp: HostAppService,
|
|
) {
|
|
super()
|
|
}
|
|
|
|
async provide (): Promise<Shell[]> {
|
|
if (this.hostApp.platform !== Platform.Windows) {
|
|
return []
|
|
}
|
|
|
|
const pwshPath = wnr.getRegistryValue(wnr.HK.LM, 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\pwsh.exe', '')
|
|
|
|
if (!pwshPath) {
|
|
return []
|
|
}
|
|
|
|
return [{
|
|
id: 'powershell-core',
|
|
name: 'PowerShell Core',
|
|
command: pwshPath,
|
|
args: ['-nologo'],
|
|
icon: require('../icons/powershell-core.svg'),
|
|
env: {
|
|
TERM: 'cygwin',
|
|
},
|
|
}]
|
|
}
|
|
}
|