mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 18:38:01 +00:00
reenabled @typescript-eslint/prefer-nullish-coalescing
This commit is contained in:
@@ -95,12 +95,12 @@ rules:
|
|||||||
- error
|
- error
|
||||||
- single
|
- single
|
||||||
- allowTemplateLiterals: true
|
- allowTemplateLiterals: true
|
||||||
|
'@typescript-eslint/no-confusing-void-expression': off
|
||||||
'@typescript-eslint/no-non-null-assertion': off
|
'@typescript-eslint/no-non-null-assertion': off
|
||||||
'@typescript-eslint/no-unnecessary-condition': off
|
'@typescript-eslint/no-unnecessary-condition': off
|
||||||
'@typescript-eslint/no-untyped-public-signature': off # bugs out on constructors
|
'@typescript-eslint/no-untyped-public-signature': off # bugs out on constructors
|
||||||
'@typescript-eslint/restrict-template-expressions': off
|
'@typescript-eslint/restrict-template-expressions': off
|
||||||
'@typescript-eslint/no-dynamic-delete': off
|
'@typescript-eslint/no-dynamic-delete': off
|
||||||
'@typescript-eslint/prefer-nullish-coalescing': off
|
|
||||||
'@typescript-eslint/prefer-readonly-parameter-types': off
|
'@typescript-eslint/prefer-readonly-parameter-types': off
|
||||||
'@typescript-eslint/no-unsafe-member-access': off
|
'@typescript-eslint/no-unsafe-member-access': off
|
||||||
'@typescript-eslint/no-unsafe-call': off
|
'@typescript-eslint/no-unsafe-call': off
|
||||||
@@ -112,7 +112,6 @@ rules:
|
|||||||
- error
|
- error
|
||||||
- exceptAfterSingleLine: true
|
- exceptAfterSingleLine: true
|
||||||
'@typescript-eslint/dot-notation': off
|
'@typescript-eslint/dot-notation': off
|
||||||
'@typescript-eslint/no-confusing-void-expression': off
|
|
||||||
'@typescript-eslint/no-implicit-any-catch': off
|
'@typescript-eslint/no-implicit-any-catch': off
|
||||||
'@typescript-eslint/member-ordering': off
|
'@typescript-eslint/member-ordering': off
|
||||||
'@typescript-eslint/no-var-requires': off
|
'@typescript-eslint/no-var-requires': off
|
||||||
|
@@ -49,7 +49,7 @@ export class Window {
|
|||||||
constructor (options?: WindowOptions) {
|
constructor (options?: WindowOptions) {
|
||||||
this.configStore = loadConfig()
|
this.configStore = loadConfig()
|
||||||
|
|
||||||
options = options || {}
|
options = options ?? {}
|
||||||
|
|
||||||
this.windowConfig = new ElectronConfig({ name: 'window' })
|
this.windowConfig = new ElectronConfig({ name: 'window' })
|
||||||
this.windowBounds = this.windowConfig.get('windowBoundaries')
|
this.windowBounds = this.windowConfig.get('windowBoundaries')
|
||||||
|
@@ -229,8 +229,8 @@ export class AppRootComponent {
|
|||||||
buttons = buttons.concat(provider.provide())
|
buttons = buttons.concat(provider.provide())
|
||||||
})
|
})
|
||||||
return buttons
|
return buttons
|
||||||
.filter(button => (button.weight || 0) > 0 === aboveZero)
|
.filter(button => (button.weight ?? 0) > 0 === aboveZero)
|
||||||
.sort((a: ToolbarButton, b: ToolbarButton) => (a.weight || 0) - (b.weight || 0))
|
.sort((a: ToolbarButton, b: ToolbarButton) => (a.weight ?? 0) - (b.weight ?? 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateVibrancy () {
|
private updateVibrancy () {
|
||||||
|
@@ -50,7 +50,7 @@ export class SelectorModalComponent<T> {
|
|||||||
this.filteredOptions = this.options.filter(x => !x.freeInputPattern)
|
this.filteredOptions = this.options.filter(x => !x.freeInputPattern)
|
||||||
} else {
|
} else {
|
||||||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
||||||
this.filteredOptions = this.options.filter(x => x.freeInputPattern || (x.name + (x.description || '')).toLowerCase().includes(f))
|
this.filteredOptions = this.options.filter(x => x.freeInputPattern ?? (x.name + (x.description ?? '')).toLowerCase().includes(f))
|
||||||
}
|
}
|
||||||
this.selectedIndex = Math.max(0, this.selectedIndex)
|
this.selectedIndex = Math.max(0, this.selectedIndex)
|
||||||
this.selectedIndex = Math.min(this.filteredOptions.length - 1, this.selectedIndex)
|
this.selectedIndex = Math.min(this.filteredOptions.length - 1, this.selectedIndex)
|
||||||
|
@@ -331,7 +331,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
|
|||||||
async addTab (tab: BaseTabComponent, relative: BaseTabComponent|null, side: SplitDirection): Promise<void> {
|
async addTab (tab: BaseTabComponent, relative: BaseTabComponent|null, side: SplitDirection): Promise<void> {
|
||||||
tab.parent = this
|
tab.parent = this
|
||||||
|
|
||||||
let target = (relative ? this.getParentOf(relative) : null) || this.root
|
let target = (relative ? this.getParentOf(relative) : null) ?? this.root
|
||||||
let insertIndex = relative ? target.children.indexOf(relative) : -1
|
let insertIndex = relative ? target.children.indexOf(relative) : -1
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -442,7 +442,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
|
|||||||
* @returns the immediate parent of `tab`
|
* @returns the immediate parent of `tab`
|
||||||
*/
|
*/
|
||||||
getParentOf (tab: BaseTabComponent | SplitContainer, root?: SplitContainer): SplitContainer|null {
|
getParentOf (tab: BaseTabComponent | SplitContainer, root?: SplitContainer): SplitContainer|null {
|
||||||
root = root || this.root
|
root = root ?? this.root
|
||||||
for (const child of root.children) {
|
for (const child of root.children) {
|
||||||
if (child instanceof SplitContainer) {
|
if (child instanceof SplitContainer) {
|
||||||
const r = this.getParentOf(tab, child)
|
const r = this.getParentOf(tab, child)
|
||||||
@@ -469,7 +469,7 @@ export class SplitTabComponent extends BaseTabComponent implements AfterViewInit
|
|||||||
|
|
||||||
/** @hidden */
|
/** @hidden */
|
||||||
async getCurrentProcess (): Promise<BaseTabProcess|null> {
|
async getCurrentProcess (): Promise<BaseTabProcess|null> {
|
||||||
return (await Promise.all(this.getAllTabs().map(x => x.getCurrentProcess()))).find(x => !!x) || null
|
return (await Promise.all(this.getAllTabs().map(x => x.getCurrentProcess()))).find(x => !!x) ?? null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @hidden */
|
/** @hidden */
|
||||||
|
@@ -26,10 +26,10 @@ export class StartPageComponent {
|
|||||||
.map(provider => provider.provide())
|
.map(provider => provider.provide())
|
||||||
.reduce((a, b) => a.concat(b))
|
.reduce((a, b) => a.concat(b))
|
||||||
.filter(x => !!x.click)
|
.filter(x => !!x.click)
|
||||||
.sort((a: ToolbarButton, b: ToolbarButton) => (a.weight || 0) - (b.weight || 0))
|
.sort((a: ToolbarButton, b: ToolbarButton) => (a.weight ?? 0) - (b.weight ?? 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
sanitizeIcon (icon: string): any {
|
sanitizeIcon (icon: string): any {
|
||||||
return this.domSanitizer.bypassSecurityTrustHtml(icon || '')
|
return this.domSanitizer.bypassSecurityTrustHtml(icon ?? '')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -97,9 +97,7 @@ export class AppService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hostApp.windowFocused$.subscribe(() => {
|
hostApp.windowFocused$.subscribe(() => this._activeTab?.emitFocused())
|
||||||
this._activeTab?.emitFocused()
|
|
||||||
})
|
|
||||||
|
|
||||||
this.tabClosed$.subscribe(async tab => {
|
this.tabClosed$.subscribe(async tab => {
|
||||||
const token = await tab.getRecoveryToken()
|
const token = await tab.getRecoveryToken()
|
||||||
|
@@ -59,7 +59,7 @@ export class ShellIntegrationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async install (): Promise<void> {
|
async install (): Promise<void> {
|
||||||
const exe: string = process.env.PORTABLE_EXECUTABLE_FILE || this.electron.app.getPath('exe')
|
const exe: string = process.env.PORTABLE_EXECUTABLE_FILE ?? this.electron.app.getPath('exe')
|
||||||
if (this.hostApp.platform === Platform.macOS) {
|
if (this.hostApp.platform === Platform.macOS) {
|
||||||
for (const wf of this.automatorWorkflows) {
|
for (const wf of this.automatorWorkflows) {
|
||||||
await exec(`cp -r "${this.automatorWorkflowsLocation}/${wf}" "${this.automatorWorkflowsDestination}"`)
|
await exec(`cp -r "${this.automatorWorkflowsLocation}/${wf}" "${this.automatorWorkflowsDestination}"`)
|
||||||
|
@@ -51,7 +51,7 @@ export class TabRecoveryService {
|
|||||||
const tab = await provider.recover(token)
|
const tab = await provider.recover(token)
|
||||||
if (tab !== null) {
|
if (tab !== null) {
|
||||||
tab.options = tab.options || {}
|
tab.options = tab.options || {}
|
||||||
tab.options.color = token.tabColor || null
|
tab.options.color = token.tabColor ?? null
|
||||||
tab.options.title = token.tabTitle || ''
|
tab.options.title = token.tabTitle || ''
|
||||||
return tab
|
return tab
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ export class TabsService {
|
|||||||
const componentRef = componentFactory.create(this.injector)
|
const componentRef = componentFactory.create(this.injector)
|
||||||
const tab = componentRef.instance
|
const tab = componentRef.instance
|
||||||
tab.hostView = componentRef.hostView
|
tab.hostView = componentRef.hostView
|
||||||
Object.assign(tab, inputs || {})
|
Object.assign(tab, inputs ?? {})
|
||||||
return tab
|
return tab
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,11 +18,11 @@ export class ThemesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
findTheme (name: string): Theme|null {
|
findTheme (name: string): Theme|null {
|
||||||
return this.config.enabledServices(this.themes).find(x => x.name === name) || null
|
return this.config.enabledServices(this.themes).find(x => x.name === name) ?? null
|
||||||
}
|
}
|
||||||
|
|
||||||
findCurrentTheme (): Theme {
|
findCurrentTheme (): Theme {
|
||||||
return this.findTheme(this.config.store.appearance.theme) || this.findTheme('Standard')!
|
return this.findTheme(this.config.store.appearance.theme) ?? this.findTheme('Standard')!
|
||||||
}
|
}
|
||||||
|
|
||||||
applyTheme (theme: Theme): void {
|
applyTheme (theme: Theme): void {
|
||||||
|
@@ -66,7 +66,7 @@ export class TouchbarService {
|
|||||||
buttons = buttons.concat(provider.provide())
|
buttons = buttons.concat(provider.provide())
|
||||||
})
|
})
|
||||||
buttons = buttons.filter(x => !!x.touchBarNSImage)
|
buttons = buttons.filter(x => !!x.touchBarNSImage)
|
||||||
buttons.sort((a, b) => (a.weight || 0) - (b.weight || 0))
|
buttons.sort((a, b) => (a.weight ?? 0) - (b.weight ?? 0))
|
||||||
this.tabSegments = this.app.tabs.map(tab => ({
|
this.tabSegments = this.app.tabs.map(tab => ({
|
||||||
label: this.shortenTitle(tab.title),
|
label: this.shortenTitle(tab.title),
|
||||||
}))
|
}))
|
||||||
@@ -102,7 +102,7 @@ export class TouchbarService {
|
|||||||
|
|
||||||
private getButton (button: ToolbarButton): SegmentedControlSegment {
|
private getButton (button: ToolbarButton): SegmentedControlSegment {
|
||||||
return {
|
return {
|
||||||
label: button.touchBarNSImage ? undefined : this.shortenTitle(button.touchBarTitle || button.title),
|
label: button.touchBarNSImage ? undefined : this.shortenTitle(button.touchBarTitle ?? button.title),
|
||||||
icon: button.touchBarNSImage ? this.getCachedNSImage(button.touchBarNSImage) : undefined,
|
icon: button.touchBarNSImage ? this.getCachedNSImage(button.touchBarNSImage) : undefined,
|
||||||
// click: () => this.zone.run(() => button.click()),
|
// click: () => this.zone.run(() => button.click()),
|
||||||
}
|
}
|
||||||
|
@@ -40,7 +40,7 @@ export class PluginManagerService {
|
|||||||
|
|
||||||
listAvailable (query?: string): Observable<PluginInfo[]> {
|
listAvailable (query?: string): Observable<PluginInfo[]> {
|
||||||
return from(
|
return from(
|
||||||
axios.get(`https://www.npmjs.com/search?q=keywords%3A${KEYWORD}+${encodeURIComponent(query || '')}&from=0&size=1000`, {
|
axios.get(`https://www.npmjs.com/search?q=keywords%3A${KEYWORD}+${encodeURIComponent(query ?? '')}&from=0&size=1000`, {
|
||||||
headers: {
|
headers: {
|
||||||
'x-spiferack': '1',
|
'x-spiferack': '1',
|
||||||
},
|
},
|
||||||
|
@@ -44,7 +44,7 @@ export class SerialSession extends BaseSession {
|
|||||||
|
|
||||||
constructor (public connection: SerialConnection) {
|
constructor (public connection: SerialConnection) {
|
||||||
super()
|
super()
|
||||||
this.scripts = connection.scripts || []
|
this.scripts = connection.scripts ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
async start (): Promise<void> {
|
async start (): Promise<void> {
|
||||||
|
@@ -37,7 +37,7 @@ export class EditConnectionModalComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async ngOnInit () {
|
async ngOnInit () {
|
||||||
this.connection.scripts = this.connection.scripts || []
|
this.connection.scripts = this.connection.scripts ?? []
|
||||||
this.foundPorts = await this.serial.listPorts()
|
this.foundPorts = await this.serial.listPorts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -57,7 +57,6 @@ export class SerialService {
|
|||||||
this.toastr.error(e.message)
|
this.toastr.error(e.message)
|
||||||
reject(e)
|
reject(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
return serial
|
return serial
|
||||||
}
|
}
|
||||||
@@ -125,7 +124,7 @@ export class SerialService {
|
|||||||
{ connection }
|
{ connection }
|
||||||
) as SerialTabComponent
|
) as SerialTabComponent
|
||||||
if (connection.color) {
|
if (connection.color) {
|
||||||
(this.app.getParentTab(tab) || tab).color = connection.color
|
(this.app.getParentTab(tab) ?? tab).color = connection.color
|
||||||
}
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.app.activeTab.emitFocused()
|
this.app.activeTab.emitFocused()
|
||||||
|
@@ -123,7 +123,7 @@ export class SSHSession extends BaseSession {
|
|||||||
|
|
||||||
constructor (public connection: SSHConnection) {
|
constructor (public connection: SSHConnection) {
|
||||||
super()
|
super()
|
||||||
this.scripts = connection.scripts || []
|
this.scripts = connection.scripts ?? []
|
||||||
this.destroyed$.subscribe(() => {
|
this.destroyed$.subscribe(() => {
|
||||||
for (const port of this.forwardedPorts) {
|
for (const port of this.forwardedPorts) {
|
||||||
if (port.type === PortForwardType.Local) {
|
if (port.type === PortForwardType.Local) {
|
||||||
@@ -232,7 +232,7 @@ export class SSHSession extends BaseSession {
|
|||||||
|
|
||||||
this.ssh.on('x11', (details, accept, reject) => {
|
this.ssh.on('x11', (details, accept, reject) => {
|
||||||
this.logger.info(`Incoming X11 connection from ${details.srcIP}:${details.srcPort}`)
|
this.logger.info(`Incoming X11 connection from ${details.srcIP}:${details.srcPort}`)
|
||||||
const displaySpec = process.env.DISPLAY || ':0'
|
const displaySpec = process.env.DISPLAY ?? ':0'
|
||||||
this.logger.debug(`Trying display ${displaySpec}`)
|
this.logger.debug(`Trying display ${displaySpec}`)
|
||||||
const xHost = displaySpec.split(':')[0]
|
const xHost = displaySpec.split(':')[0]
|
||||||
const xDisplay = parseInt(displaySpec.split(':')[1].split('.')[0] || '0')
|
const xDisplay = parseInt(displaySpec.split(':')[1].split('.')[0] || '0')
|
||||||
@@ -273,15 +273,14 @@ export class SSHSession extends BaseSession {
|
|||||||
await fw.startLocalListener((accept, reject, sourceAddress, sourcePort, targetAddress, targetPort) => {
|
await fw.startLocalListener((accept, reject, sourceAddress, sourcePort, targetAddress, targetPort) => {
|
||||||
this.logger.info(`New connection on ${fw}`)
|
this.logger.info(`New connection on ${fw}`)
|
||||||
this.ssh.forwardOut(
|
this.ssh.forwardOut(
|
||||||
sourceAddress || '127.0.0.1',
|
sourceAddress ?? '127.0.0.1',
|
||||||
sourcePort || 0,
|
sourcePort ?? 0,
|
||||||
targetAddress,
|
targetAddress,
|
||||||
targetPort,
|
targetPort,
|
||||||
(err, stream) => {
|
(err, stream) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
this.emitServiceMessage(colors.bgRed.black(' X ') + ` Remote has rejected the forwarded connection to ${targetAddress}:${targetPort} via ${fw}: ${err}`)
|
this.emitServiceMessage(colors.bgRed.black(' X ') + ` Remote has rejected the forwarded connection to ${targetAddress}:${targetPort} via ${fw}: ${err}`)
|
||||||
reject()
|
return reject()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if (stream) {
|
if (stream) {
|
||||||
const socket = accept()
|
const socket = accept()
|
||||||
@@ -345,7 +344,7 @@ export class SSHSession extends BaseSession {
|
|||||||
|
|
||||||
kill (signal?: string): void {
|
kill (signal?: string): void {
|
||||||
if (this.shell) {
|
if (this.shell) {
|
||||||
this.shell.signal(signal || 'TERM')
|
this.shell.signal(signal ?? 'TERM')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -47,9 +47,9 @@ export class EditConnectionModalComponent {
|
|||||||
|
|
||||||
async ngOnInit () {
|
async ngOnInit () {
|
||||||
this.hasSavedPassword = !!await this.passwordStorage.loadPassword(this.connection)
|
this.hasSavedPassword = !!await this.passwordStorage.loadPassword(this.connection)
|
||||||
this.connection.algorithms = this.connection.algorithms || {}
|
this.connection.algorithms = this.connection.algorithms ?? {}
|
||||||
this.connection.scripts = this.connection.scripts || []
|
this.connection.scripts = this.connection.scripts ?? []
|
||||||
this.connection.auth = this.connection.auth || null
|
this.connection.auth = this.connection.auth ?? null
|
||||||
|
|
||||||
for (const k of Object.values(SSHAlgorithmType)) {
|
for (const k of Object.values(SSHAlgorithmType)) {
|
||||||
if (!this.connection.algorithms[k]) {
|
if (!this.connection.algorithms[k]) {
|
||||||
|
@@ -127,7 +127,7 @@ export class SSHSettingsTabComponent {
|
|||||||
this.childGroups = []
|
this.childGroups = []
|
||||||
|
|
||||||
for (const connection of this.connections) {
|
for (const connection of this.connections) {
|
||||||
connection.group = connection.group || null
|
connection.group = connection.group ?? null
|
||||||
let group = this.childGroups.find(x => x.name === connection.group)
|
let group = this.childGroups.find(x => x.name === connection.group)
|
||||||
if (!group) {
|
if (!group) {
|
||||||
group = {
|
group = {
|
||||||
|
@@ -249,12 +249,12 @@ export class SSHService {
|
|||||||
try {
|
try {
|
||||||
ssh.connect({
|
ssh.connect({
|
||||||
host: session.connection.host,
|
host: session.connection.host,
|
||||||
port: session.connection.port || 22,
|
port: session.connection.port ?? 22,
|
||||||
username: session.connection.user,
|
username: session.connection.user,
|
||||||
password: session.connection.privateKey ? undefined : '',
|
password: session.connection.privateKey ? undefined : '',
|
||||||
privateKey: privateKey || undefined,
|
privateKey: privateKey ?? undefined,
|
||||||
tryKeyboard: true,
|
tryKeyboard: true,
|
||||||
agent: agent || undefined,
|
agent: agent ?? undefined,
|
||||||
agentForward: session.connection.agentForward && !!agent,
|
agentForward: session.connection.agentForward && !!agent,
|
||||||
keepaliveInterval: session.connection.keepaliveInterval,
|
keepaliveInterval: session.connection.keepaliveInterval,
|
||||||
keepaliveCountMax: session.connection.keepaliveCountMax,
|
keepaliveCountMax: session.connection.keepaliveCountMax,
|
||||||
@@ -284,7 +284,7 @@ export class SSHService {
|
|||||||
} as any)
|
} as any)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.toastr.error(e.message)
|
this.toastr.error(e.message)
|
||||||
reject(e)
|
return reject(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
let keychainPasswordUsed = false
|
let keychainPasswordUsed = false
|
||||||
@@ -398,12 +398,10 @@ export class SSHService {
|
|||||||
{ connection }
|
{ connection }
|
||||||
) as SSHTabComponent
|
) as SSHTabComponent
|
||||||
if (connection.color) {
|
if (connection.color) {
|
||||||
(this.app.getParentTab(tab) || tab).color = connection.color
|
(this.app.getParentTab(tab) ?? tab).color = connection.color
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => this.app.activeTab?.emitFocused())
|
||||||
this.app.activeTab?.emitFocused()
|
|
||||||
})
|
|
||||||
|
|
||||||
return tab
|
return tab
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@@ -17,7 +17,7 @@ export abstract class TerminalDecorator {
|
|||||||
* Make sure to call super()
|
* Make sure to call super()
|
||||||
*/
|
*/
|
||||||
detach (terminal: BaseTerminalTabComponent): void {
|
detach (terminal: BaseTerminalTabComponent): void {
|
||||||
for (const s of this.smartSubscriptions.get(terminal) || []) {
|
for (const s of this.smartSubscriptions.get(terminal) ?? []) {
|
||||||
s.unsubscribe()
|
s.unsubscribe()
|
||||||
}
|
}
|
||||||
this.smartSubscriptions.delete(terminal)
|
this.smartSubscriptions.delete(terminal)
|
||||||
|
@@ -93,11 +93,11 @@ export class ColorSchemeSettingsTabComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCurrentSchemeName () {
|
getCurrentSchemeName () {
|
||||||
return (this.currentCustomScheme || this.currentStockScheme)?.name || 'Custom'
|
return (this.currentCustomScheme ?? this.currentStockScheme)?.name ?? 'Custom'
|
||||||
}
|
}
|
||||||
|
|
||||||
findMatchingScheme (scheme: TerminalColorScheme, schemes: TerminalColorScheme[]) {
|
findMatchingScheme (scheme: TerminalColorScheme, schemes: TerminalColorScheme[]) {
|
||||||
return schemes.find(x => deepEqual(x, scheme)) || null
|
return schemes.find(x => deepEqual(x, scheme)) ?? null
|
||||||
}
|
}
|
||||||
|
|
||||||
colorsTrackBy (index) {
|
colorsTrackBy (index) {
|
||||||
|
@@ -18,8 +18,8 @@ export class EditProfileModalComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.profile.sessionOptions.env = this.profile.sessionOptions.env || {}
|
this.profile.sessionOptions.env = this.profile.sessionOptions.env ?? {}
|
||||||
this.profile.sessionOptions.args = this.profile.sessionOptions.args || []
|
this.profile.sessionOptions.args = this.profile.sessionOptions.args ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
save () {
|
save () {
|
||||||
|
@@ -67,7 +67,7 @@ export class ShellSettingsTabComponent {
|
|||||||
|
|
||||||
newProfile (shell: Shell): void {
|
newProfile (shell: Shell): void {
|
||||||
const profile: Profile = {
|
const profile: Profile = {
|
||||||
name: shell.name || '',
|
name: shell.name ?? '',
|
||||||
shell: shell.id,
|
shell: shell.id,
|
||||||
sessionOptions: this.terminal.optionsFromShell(shell),
|
sessionOptions: this.terminal.optionsFromShell(shell),
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent {
|
|||||||
type: 'app:terminal-tab',
|
type: 'app:terminal-tab',
|
||||||
sessionOptions: {
|
sessionOptions: {
|
||||||
...this.sessionOptions,
|
...this.sessionOptions,
|
||||||
cwd: cwd || this.sessionOptions.cwd,
|
cwd: cwd ?? this.sessionOptions.cwd,
|
||||||
},
|
},
|
||||||
savedState: this.frontend?.saveState(),
|
savedState: this.frontend?.saveState(),
|
||||||
}
|
}
|
||||||
|
@@ -102,7 +102,7 @@ export class Session extends BaseSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start (options: SessionOptions): void {
|
start (options: SessionOptions): void {
|
||||||
this.name = options.name || ''
|
this.name = options.name ?? ''
|
||||||
|
|
||||||
const env = {
|
const env = {
|
||||||
...process.env,
|
...process.env,
|
||||||
@@ -113,7 +113,7 @@ export class Session extends BaseSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (process.platform === 'darwin' && !process.env.LC_ALL) {
|
if (process.platform === 'darwin' && !process.env.LC_ALL) {
|
||||||
const locale = process.env.LC_CTYPE || 'en_US.UTF-8'
|
const locale = process.env.LC_CTYPE ?? 'en_US.UTF-8'
|
||||||
Object.assign(env, {
|
Object.assign(env, {
|
||||||
LANG: locale,
|
LANG: locale,
|
||||||
LC_ALL: locale,
|
LC_ALL: locale,
|
||||||
@@ -124,17 +124,17 @@ export class Session extends BaseSession {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let cwd = options.cwd || process.env.HOME
|
let cwd = options.cwd ?? process.env.HOME
|
||||||
|
|
||||||
if (!fs.existsSync(cwd)) {
|
if (!fs.existsSync(cwd)) {
|
||||||
console.warn('Ignoring non-existent CWD:', cwd)
|
console.warn('Ignoring non-existent CWD:', cwd)
|
||||||
cwd = undefined
|
cwd = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
this.pty = nodePTY.spawn(options.command, options.args || [], {
|
this.pty = nodePTY.spawn(options.command, options.args ?? [], {
|
||||||
name: 'xterm-256color',
|
name: 'xterm-256color',
|
||||||
cols: options.width || 80,
|
cols: options.width ?? 80,
|
||||||
rows: options.height || 30,
|
rows: options.height ?? 30,
|
||||||
encoding: null,
|
encoding: null,
|
||||||
cwd,
|
cwd,
|
||||||
env: env,
|
env: env,
|
||||||
@@ -142,7 +142,7 @@ export class Session extends BaseSession {
|
|||||||
useConpty: (isWindowsBuild(WIN_BUILD_CONPTY_SUPPORTED) && this.config.store.terminal.useConPTY ? 1 : false) as any,
|
useConpty: (isWindowsBuild(WIN_BUILD_CONPTY_SUPPORTED) && this.config.store.terminal.useConPTY ? 1 : false) as any,
|
||||||
})
|
})
|
||||||
|
|
||||||
this.guessedCWD = cwd || null
|
this.guessedCWD = cwd ?? null
|
||||||
|
|
||||||
this.truePID = this.pty['pid']
|
this.truePID = this.pty['pid']
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ export class Session extends BaseSession {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
this.pauseAfterExit = options.pauseAfterExit || false
|
this.pauseAfterExit = options.pauseAfterExit ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
resize (columns: number, rows: number): void {
|
resize (columns: number, rows: number): void {
|
||||||
|
@@ -38,6 +38,7 @@ export class TerminalService {
|
|||||||
const shells = await this.shells$.toPromise()
|
const shells = await this.shells$.toPromise()
|
||||||
return [
|
return [
|
||||||
...this.config.store.terminal.profiles,
|
...this.config.store.terminal.profiles,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||||
...skipDefault ? [] : shells.filter(x => includeHidden || !x.hidden).map(shell => ({
|
...skipDefault ? [] : shells.filter(x => includeHidden || !x.hidden).map(shell => ({
|
||||||
name: shell.name,
|
name: shell.name,
|
||||||
shell: shell.id,
|
shell: shell.id,
|
||||||
@@ -54,7 +55,7 @@ export class TerminalService {
|
|||||||
|
|
||||||
async getProfileByID (id: string): Promise<Profile> {
|
async getProfileByID (id: string): Promise<Profile> {
|
||||||
const profiles = await this.getProfiles({ includeHidden: true })
|
const profiles = await this.getProfiles({ includeHidden: true })
|
||||||
return profiles.find(x => this.getProfileID(x) === id) || profiles[0]
|
return profiles.find(x => this.getProfileID(x) === id) ?? profiles[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,7 +70,7 @@ export class TerminalService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cwd = cwd || profile.sessionOptions.cwd
|
cwd = cwd ?? profile.sessionOptions.cwd
|
||||||
|
|
||||||
if (cwd && !fs.existsSync(cwd)) {
|
if (cwd && !fs.existsSync(cwd)) {
|
||||||
console.warn('Ignoring non-existent CWD:', cwd)
|
console.warn('Ignoring non-existent CWD:', cwd)
|
||||||
@@ -89,20 +90,19 @@ export class TerminalService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cwd = cwd || this.config.store.terminal.workingDirectory
|
cwd = cwd ?? this.config.store.terminal.workingDirectory
|
||||||
cwd = cwd || null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.info(`Starting profile ${profile.name}`, profile)
|
this.logger.info(`Starting profile ${profile.name}`, profile)
|
||||||
const sessionOptions = {
|
const sessionOptions = {
|
||||||
...profile.sessionOptions,
|
...profile.sessionOptions,
|
||||||
pauseAfterExit: pause,
|
pauseAfterExit: pause,
|
||||||
cwd: cwd || undefined,
|
cwd: cwd ?? undefined,
|
||||||
}
|
}
|
||||||
|
|
||||||
const tab = this.openTabWithOptions(sessionOptions)
|
const tab = this.openTabWithOptions(sessionOptions)
|
||||||
if (profile?.color) {
|
if (profile?.color) {
|
||||||
(this.app.getParentTab(tab) || tab).color = profile.color
|
(this.app.getParentTab(tab) ?? tab).color = profile.color
|
||||||
}
|
}
|
||||||
return tab
|
return tab
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ export class TerminalService {
|
|||||||
optionsFromShell (shell: Shell): SessionOptions {
|
optionsFromShell (shell: Shell): SessionOptions {
|
||||||
return {
|
return {
|
||||||
command: shell.command,
|
command: shell.command,
|
||||||
args: shell.args || [],
|
args: shell.args ?? [],
|
||||||
env: shell.env,
|
env: shell.env,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider {
|
|||||||
const profile = {
|
const profile = {
|
||||||
sessionOptions: {
|
sessionOptions: {
|
||||||
...tab.sessionOptions,
|
...tab.sessionOptions,
|
||||||
cwd: await tab.session.getWorkingDirectory() || tab.sessionOptions.cwd,
|
cwd: await tab.session.getWorkingDirectory() ?? tab.sessionOptions.cwd,
|
||||||
},
|
},
|
||||||
name: tab.sessionOptions.command,
|
name: tab.sessionOptions.command,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user