mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-23 18:44:20 +03:00
cache dscl output
This commit is contained in:
parent
61a46e3b4a
commit
6bad2a2167
@ -8,6 +8,8 @@ import { Shell } from '../api/interfaces'
|
||||
/** @hidden */
|
||||
@Injectable()
|
||||
export class MacOSDefaultShellProvider extends ShellProvider {
|
||||
private cachedShell?: string
|
||||
|
||||
constructor (
|
||||
private hostApp: HostAppService,
|
||||
) {
|
||||
@ -18,14 +20,29 @@ export class MacOSDefaultShellProvider extends ShellProvider {
|
||||
if (this.hostApp.platform !== Platform.macOS) {
|
||||
return []
|
||||
}
|
||||
const shellEntry = (await exec(`/usr/bin/dscl . -read /Users/${process.env.LOGNAME} UserShell`))[0].toString()
|
||||
return [{
|
||||
id: 'default',
|
||||
name: 'User default',
|
||||
command: shellEntry.split(' ')[1].trim(),
|
||||
command: await this.getDefaultShellCached(),
|
||||
args: ['--login'],
|
||||
hidden: true,
|
||||
env: {},
|
||||
}]
|
||||
}
|
||||
|
||||
private async getDefaultShellCached () {
|
||||
if (!this.cachedShell) {
|
||||
this.cachedShell = await this.getDefaultShell()
|
||||
} else {
|
||||
this.getDefaultShell().then(shell => {
|
||||
this.cachedShell = shell
|
||||
})
|
||||
}
|
||||
return this.cachedShell!
|
||||
}
|
||||
|
||||
private async getDefaultShell () {
|
||||
const shellEntry = (await exec(`/usr/bin/dscl . -read /Users/${process.env.LOGNAME} UserShell`))[0].toString()
|
||||
return shellEntry.split(' ')[1].trim()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user