mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-22 18:11:43 +03:00
auto-search powershell $PATH
This commit is contained in:
parent
730084425e
commit
601fff454d
@ -22,6 +22,7 @@
|
||||
"devDependencies": {
|
||||
"ansi-colors": "^4.1.1",
|
||||
"dataurl": "0.1.0",
|
||||
"hasbin": "^1.2.3",
|
||||
"ps-node": "^0.1.6",
|
||||
"runes": "^0.4.2",
|
||||
"utils-decorators": "^1.8.3"
|
||||
|
@ -1,4 +1,7 @@
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs/promises'
|
||||
import hasbin from 'hasbin'
|
||||
import { promisify } from 'util'
|
||||
import { Injectable } from '@angular/core'
|
||||
import { HostAppService, Platform } from 'tabby-core'
|
||||
import { ElectronService } from 'tabby-electron'
|
||||
@ -59,7 +62,7 @@ export class WindowsStockShellsProvider extends ShellProvider {
|
||||
{
|
||||
id: 'powershell',
|
||||
name: 'PowerShell',
|
||||
command: 'powershell.exe',
|
||||
command: await this.getPowerShellPath(),
|
||||
args: ['-nologo'],
|
||||
icon: require('../icons/powershell.svg'),
|
||||
env: {
|
||||
@ -68,4 +71,23 @@ export class WindowsStockShellsProvider extends ShellProvider {
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
private async getPowerShellPath () {
|
||||
const ps = 'powershell.exe'
|
||||
|
||||
if (!await promisify(hasbin)(ps)) {
|
||||
for (const searchPath of [
|
||||
`${process.env.SystemRoot}\\System32\\WindowsPowerShell\\v1.0`,
|
||||
`${process.env.SystemRoot}\\System32`,
|
||||
process.env.SystemRoot ?? 'C:\\Windows',
|
||||
]) {
|
||||
const newPath = path.join(searchPath, ps)
|
||||
try {
|
||||
await fs.stat(newPath)
|
||||
return newPath
|
||||
} catch { }
|
||||
}
|
||||
}
|
||||
return ps
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,11 @@ ansi-colors@^4.1.1:
|
||||
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
|
||||
integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==
|
||||
|
||||
async@~1.5:
|
||||
version "1.5.2"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
|
||||
integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=
|
||||
|
||||
connected-domain@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/connected-domain/-/connected-domain-1.0.0.tgz#bfe77238c74be453a79f0cb6058deeb4f2358e93"
|
||||
@ -17,6 +22,13 @@ dataurl@0.1.0:
|
||||
resolved "https://registry.yarnpkg.com/dataurl/-/dataurl-0.1.0.tgz#1f4734feddec05ffe445747978d86759c4b33199"
|
||||
integrity sha1-H0c0/t3sBf/kRXR5eNhnWcSzMZk=
|
||||
|
||||
hasbin@^1.2.3:
|
||||
version "1.2.3"
|
||||
resolved "https://registry.yarnpkg.com/hasbin/-/hasbin-1.2.3.tgz#78c5926893c80215c2b568ae1fd3fcab7a2696b0"
|
||||
integrity sha1-eMWSaJPIAhXCtWiuH9P8q3omlrA=
|
||||
dependencies:
|
||||
async "~1.5"
|
||||
|
||||
opentype.js@^1.3.3:
|
||||
version "1.3.3"
|
||||
resolved "https://registry.yarnpkg.com/opentype.js/-/opentype.js-1.3.3.tgz#65b8645b090a1ad444065b784d442fa19d1061f6"
|
||||
|
Loading…
Reference in New Issue
Block a user