mirror of
https://github.com/Eugeny/tabby.git
synced 2025-10-04 05:54:57 +00:00
strict null checks
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "terminus-terminal",
|
||||
"version": "1.0.83-nightly.4",
|
||||
"version": "1.0.92-nightly.0",
|
||||
"description": "Terminus' terminal emulation core",
|
||||
"keywords": [
|
||||
"terminus-builtin-plugin"
|
||||
|
@@ -43,7 +43,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
|
||||
@ViewChild('content') content
|
||||
|
||||
/** @hidden */
|
||||
@HostBinding('style.background-color') backgroundColor: string
|
||||
@HostBinding('style.background-color') backgroundColor: string|null = null
|
||||
|
||||
/** @hidden */
|
||||
@HostBinding('class.top-padded') topPadded: boolean
|
||||
|
@@ -18,7 +18,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
||||
for (const arg of argv.slice(1).concat([electron.remote.process.argv0])) {
|
||||
if (await fs.exists(arg)) {
|
||||
if ((await fs.stat(arg)).isDirectory()) {
|
||||
this.terminal.openTab(null, arg)
|
||||
this.terminal.openTab(undefined, arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import { TerminalColorScheme } from './api/interfaces'
|
||||
@Injectable()
|
||||
export class HyperColorSchemes extends TerminalColorSchemeProvider {
|
||||
async getSchemes (): Promise<TerminalColorScheme[]> {
|
||||
const pluginsPath = path.join(process.env.HOME, '.hyper_plugins', 'node_modules')
|
||||
const pluginsPath = path.join(process.env.HOME as string, '.hyper_plugins', 'node_modules')
|
||||
if (!await fs.exists(pluginsPath)) {
|
||||
return []
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ export class AppearanceSettingsTabComponent {
|
||||
fonts: string[] = []
|
||||
colorSchemes: TerminalColorScheme[] = []
|
||||
equalComparator = deepEqual
|
||||
editingColorScheme: TerminalColorScheme
|
||||
editingColorScheme: TerminalColorScheme|null = null
|
||||
schemeChanged = false
|
||||
|
||||
constructor (
|
||||
@@ -68,7 +68,7 @@ export class AppearanceSettingsTabComponent {
|
||||
|
||||
saveScheme () {
|
||||
let schemes = this.config.store.terminal.customColorSchemes
|
||||
schemes = schemes.filter(x => x !== this.editingColorScheme && x.name !== this.editingColorScheme.name)
|
||||
schemes = schemes.filter(x => x !== this.editingColorScheme && x.name !== this.editingColorScheme!.name)
|
||||
schemes.push(this.editingColorScheme)
|
||||
this.config.store.terminal.customColorSchemes = schemes
|
||||
this.config.save()
|
||||
|
@@ -52,6 +52,9 @@ export class ShellSettingsTabComponent {
|
||||
|
||||
pickWorkingDirectory () {
|
||||
const shell = this.shells.find(x => x.id === this.config.store.terminal.shell)
|
||||
if (!shell) {
|
||||
return
|
||||
}
|
||||
const paths = this.electron.dialog.showOpenDialog(
|
||||
this.hostApp.getWindow(),
|
||||
{
|
||||
@@ -66,7 +69,7 @@ export class ShellSettingsTabComponent {
|
||||
|
||||
newProfile (shell: Shell) {
|
||||
const profile: Profile = {
|
||||
name: shell.name,
|
||||
name: shell.name || '',
|
||||
sessionOptions: this.terminalService.optionsFromShell(shell),
|
||||
}
|
||||
this.config.store.terminal.profiles = [profile, ...this.config.store.terminal.profiles]
|
||||
|
@@ -16,7 +16,7 @@ export class TerminalSettingsTabComponent {
|
||||
openWSLVolumeMixer () {
|
||||
this.electron.shell.openItem('sndvol.exe')
|
||||
this.terminal.openTab({
|
||||
name: null,
|
||||
name: '',
|
||||
sessionOptions: {
|
||||
command: 'wsl.exe',
|
||||
args: ['tput', 'bel'],
|
||||
|
@@ -68,7 +68,7 @@ export class TerminalTabComponent extends BaseTerminalTabComponent {
|
||||
}
|
||||
}
|
||||
|
||||
async getCurrentProcess (): Promise<BaseTabProcess> {
|
||||
async getCurrentProcess (): Promise<BaseTabProcess|null> {
|
||||
const children = await this.session.getChildProcesses()
|
||||
if (!children.length) {
|
||||
return null
|
||||
|
@@ -78,11 +78,11 @@ hterm.hterm.VT.CSI[' q'] = function (parseState) {
|
||||
}
|
||||
|
||||
hterm.hterm.VT.OSC['4'] = function (parseState) {
|
||||
const args = parseState.args[0].split(';')
|
||||
const args: string[] = parseState.args[0].split(';')
|
||||
|
||||
const pairCount = args.length / 2
|
||||
const colorPalette = this.terminal.getTextAttributes().colorPalette
|
||||
const responseArray = []
|
||||
const responseArray: string[] = []
|
||||
|
||||
for (let pairNumber = 0; pairNumber < pairCount; ++pairNumber) {
|
||||
const colorIndex = parseInt(args[pairNumber * 2])
|
||||
@@ -95,7 +95,7 @@ hterm.hterm.VT.OSC['4'] = function (parseState) {
|
||||
if (colorValue === '?') {
|
||||
colorValue = hterm.lib.colors.rgbToX11(colorPalette[colorIndex])
|
||||
if (colorValue) {
|
||||
responseArray.push(colorIndex + ';' + colorValue)
|
||||
responseArray.push(colorIndex.toString() + ';' + colorValue)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
@@ -186,7 +186,7 @@ export class HTermFrontend extends Frontend {
|
||||
this.io.onTerminalResize = (columns, rows) => {
|
||||
this.resize.next({ columns, rows })
|
||||
}
|
||||
this.ready.next(null)
|
||||
this.ready.next()
|
||||
this.ready.complete()
|
||||
|
||||
this.term.scrollPort_.document_.addEventListener('dragOver', event => {
|
||||
|
@@ -120,7 +120,7 @@ export class XTermFrontend extends Frontend {
|
||||
this.xterm.loadAddon(new WebglAddon())
|
||||
}
|
||||
|
||||
this.ready.next(null)
|
||||
this.ready.next()
|
||||
this.ready.complete()
|
||||
|
||||
this.xterm.loadAddon(this.search)
|
||||
@@ -250,7 +250,7 @@ export class XTermFrontend extends Frontend {
|
||||
let html = `<div style="font-family: '${this.configService.store.terminal.font}', monospace; white-space: pre">`
|
||||
const selection = this.xterm.getSelectionPosition()
|
||||
if (!selection) {
|
||||
return null
|
||||
return ''
|
||||
}
|
||||
if (selection.startRow === selection.endRow) {
|
||||
html += this.getLineAsHTML(selection.startRow, selection.startColumn, selection.endColumn)
|
||||
@@ -278,7 +278,7 @@ export class XTermFrontend extends Frontend {
|
||||
|
||||
private getLineAsHTML (y: number, start: number, end: number): string {
|
||||
let html = '<div>'
|
||||
let lastStyle = null
|
||||
let lastStyle: string|null = null
|
||||
const line = (this.xterm.buffer.getLine(y) as any)._line
|
||||
const cell = new CellData()
|
||||
for (let i = start; i < end; i++) {
|
||||
|
@@ -188,7 +188,7 @@ export default class TerminalModule { // eslint-disable-line @typescript-eslint/
|
||||
hostApp.cliOpenDirectory$.subscribe(async directory => {
|
||||
if (await fs.exists(directory)) {
|
||||
if ((await fs.stat(directory)).isDirectory()) {
|
||||
terminal.openTab(null, directory)
|
||||
terminal.openTab(undefined, directory)
|
||||
hostApp.bringToFront()
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ export class PathDropDecorator extends TerminalDecorator {
|
||||
event.preventDefault()
|
||||
}),
|
||||
terminal.frontend.drop$.subscribe(event => {
|
||||
for (const file of event.dataTransfer.files as any) {
|
||||
for (const file of event.dataTransfer!.files as any) {
|
||||
this.injectPath(terminal, file.path)
|
||||
}
|
||||
event.preventDefault()
|
||||
|
@@ -6,7 +6,7 @@ import { TerminalTabComponent } from './components/terminalTab.component'
|
||||
/** @hidden */
|
||||
@Injectable()
|
||||
export class RecoveryProvider extends TabRecoveryProvider {
|
||||
async recover (recoveryToken: any): Promise<RecoveredTab> {
|
||||
async recover (recoveryToken: any): Promise<RecoveredTab|null> {
|
||||
if (recoveryToken && recoveryToken.type === 'app:terminal-tab') {
|
||||
return {
|
||||
type: TerminalTabComponent,
|
||||
|
@@ -30,7 +30,7 @@ export class DockMenuService {
|
||||
iconPath: process.execPath,
|
||||
iconIndex: 0,
|
||||
})),
|
||||
}] : null)
|
||||
}] : null as any)
|
||||
}
|
||||
if (this.hostApp.platform === Platform.macOS) {
|
||||
this.electron.app.dock.setMenu(this.electron.Menu.buildFromTemplate(
|
||||
|
@@ -62,7 +62,7 @@ export abstract class BaseSession {
|
||||
releaseInitialDataBuffer () {
|
||||
this.initialDataBufferReleased = true
|
||||
this.output.next(this.initialDataBuffer)
|
||||
this.initialDataBuffer = null
|
||||
this.initialDataBuffer = ''
|
||||
}
|
||||
|
||||
async destroy (): Promise<void> {
|
||||
@@ -81,14 +81,14 @@ export abstract class BaseSession {
|
||||
abstract kill (signal?: string): void
|
||||
abstract async getChildProcesses (): Promise<ChildProcess[]>
|
||||
abstract async gracefullyKillProcess (): Promise<void>
|
||||
abstract async getWorkingDirectory (): Promise<string>
|
||||
abstract async getWorkingDirectory (): Promise<string|null>
|
||||
}
|
||||
|
||||
/** @hidden */
|
||||
export class Session extends BaseSession {
|
||||
private pty: any
|
||||
private pauseAfterExit = false
|
||||
private guessedCWD: string
|
||||
private guessedCWD: string|null = null
|
||||
private reportedCWD: string
|
||||
|
||||
constructor (private config: ConfigService) {
|
||||
@@ -96,7 +96,7 @@ export class Session extends BaseSession {
|
||||
}
|
||||
|
||||
start (options: SessionOptions) {
|
||||
this.name = options.name
|
||||
this.name = options.name || ''
|
||||
|
||||
const env = {
|
||||
...process.env,
|
||||
@@ -122,7 +122,7 @@ export class Session extends BaseSession {
|
||||
|
||||
if (!fs.existsSync(cwd)) {
|
||||
console.warn('Ignoring non-existent CWD:', cwd)
|
||||
cwd = null
|
||||
cwd = undefined
|
||||
}
|
||||
|
||||
this.pty = nodePTY.spawn(options.command, options.args || [], {
|
||||
@@ -135,7 +135,7 @@ export class Session extends BaseSession {
|
||||
experimentalUseConpty: (isWindowsBuild(WIN_BUILD_CONPTY_SUPPORTED) && this.config.store.terminal.useConPTY ? 1 : false) as any,
|
||||
})
|
||||
|
||||
this.guessedCWD = cwd
|
||||
this.guessedCWD = cwd || null
|
||||
|
||||
this.truePID = this.pty['pid']
|
||||
|
||||
@@ -174,7 +174,7 @@ export class Session extends BaseSession {
|
||||
}
|
||||
})
|
||||
|
||||
this.pauseAfterExit = options.pauseAfterExit
|
||||
this.pauseAfterExit = options.pauseAfterExit || false
|
||||
}
|
||||
|
||||
processOSC1337 (data: string) {
|
||||
@@ -270,7 +270,7 @@ export class Session extends BaseSession {
|
||||
}
|
||||
}
|
||||
|
||||
async getWorkingDirectory (): Promise<string> {
|
||||
async getWorkingDirectory (): Promise<string|null> {
|
||||
if (this.reportedCWD) {
|
||||
return this.reportedCWD
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ export class TerminalService {
|
||||
* Launches a new terminal with a specific shell and CWD
|
||||
* @param pause Wait for a keypress when the shell exits
|
||||
*/
|
||||
async openTab (profile?: Profile, cwd?: string, pause?: boolean): Promise<TerminalTabComponent> {
|
||||
async openTab (profile?: Profile, cwd?: string|null, pause?: boolean): Promise<TerminalTabComponent> {
|
||||
if (!profile) {
|
||||
const profiles = await this.getProfiles(true)
|
||||
profile = profiles.find(x => slug(x.name).toLowerCase() === this.config.store.terminal.profile) || profiles[0]
|
||||
@@ -85,7 +85,7 @@ export class TerminalService {
|
||||
const sessionOptions = {
|
||||
...profile.sessionOptions,
|
||||
pauseAfterExit: pause,
|
||||
cwd,
|
||||
cwd: cwd || undefined,
|
||||
}
|
||||
|
||||
return this.openTabWithOptions(sessionOptions)
|
||||
|
@@ -34,6 +34,6 @@ export class TerminalFrontendService {
|
||||
this.getFrontend(),
|
||||
)
|
||||
}
|
||||
return this.containers.get(session)
|
||||
return this.containers.get(session)!
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ export class LinuxDefaultShellProvider extends ShellProvider {
|
||||
return []
|
||||
}
|
||||
const line = (await fs.readFile('/etc/passwd', { encoding: 'utf-8' }))
|
||||
.split('\n').find(x => x.startsWith(process.env.LOGNAME + ':'))
|
||||
.split('\n').find(x => x.startsWith(`${process.env.LOGNAME}:`))
|
||||
if (!line) {
|
||||
this.logger.warn('Could not detect user shell')
|
||||
return [{
|
||||
|
Reference in New Issue
Block a user