Преглед изворни кода

set Terminus as COMSPEC inside shells - fixes #3643

Eugene Pankov пре 4 година
родитељ
комит
7398d776be

+ 1 - 0
app/common.ts

@@ -1,3 +1,4 @@
 export interface BootstrapData {
     config: Record<string, any>
+    executable: string
 }

+ 1 - 1
app/lib/cli.ts

@@ -10,7 +10,7 @@ export function parseArgs (argv: string[], cwd: string): any {
         .command('open [directory]', 'open a shell in a directory', {
             directory: { type: 'string', 'default': cwd },
         })
-        .command('run [command...]', 'run a command in the terminal', {
+        .command(['run [command...]', '/k'], 'run a command in the terminal', {
             command: { type: 'string' },
         })
         .command('profile [profileName]', 'open a tab with specified profile', {

+ 1 - 0
app/lib/window.ts

@@ -296,6 +296,7 @@ export class Window {
             }
             this.window.webContents.send('start', {
                 config: this.configStore,
+                executable: app.getPath('exe'),
             })
         })
 

+ 2 - 0
app/src/entry.ts

@@ -54,6 +54,8 @@ async function bootstrap (plugins: PluginInfo[], bootstrapData: BootstrapData, s
 
 ipcRenderer.once('start', async (_$event, bootstrapData: BootstrapData) => {
     console.log('Window bootstrap data:', bootstrapData)
+    ;(window as any).bootstrapData = bootstrapData
+
     let plugins = await findPlugins()
     if (bootstrapData.config.pluginBlacklist) {
         plugins = plugins.filter(x => !bootstrapData.config.pluginBlacklist.includes(x.name))

+ 1 - 1
scripts/vars.js

@@ -17,8 +17,8 @@ if (exports.version.includes('-c')) {
 exports.builtinPlugins = [
   'terminus-core',
   'terminus-settings',
-  'terminus-local',
   'terminus-terminal',
+  'terminus-local',
   'terminus-community-color-schemes',
   'terminus-plugin-manager',
   'terminus-ssh',

+ 1 - 0
terminus-core/src/api/index.ts

@@ -10,6 +10,7 @@ export { Theme } from './theme'
 export { TabContextMenuItemProvider } from './tabContextMenuProvider'
 export { SelectorOption } from './selector'
 export { CLIHandler, CLIEvent } from './cli'
+export { BootstrapData } from './main-process'
 
 export { AppService } from '../services/app.service'
 export { ConfigService } from '../services/config.service'

+ 4 - 0
terminus-core/src/api/main-process.ts

@@ -0,0 +1,4 @@
+export interface BootstrapData {
+    config: Record<string, any>
+    executable: string
+}

+ 4 - 0
terminus-core/src/api/mainProcess.ts

@@ -0,0 +1,4 @@
+export interface BootstrapData {
+    config: Record<string, any>
+    executable: string
+}

+ 5 - 6
terminus-core/src/index.ts

@@ -24,12 +24,7 @@ import { WelcomeTabComponent } from './components/welcomeTab.component'
 import { AutofocusDirective } from './directives/autofocus.directive'
 import { FastHtmlBindDirective } from './directives/fastHtmlBind.directive'
 
-import { HotkeyProvider } from './api/hotkeyProvider'
-import { ConfigProvider } from './api/configProvider'
-import { Theme } from './api/theme'
-import { CLIHandler } from './api/cli'
-import { TabContextMenuItemProvider } from './api/tabContextMenuProvider'
-import { TabRecoveryProvider } from './api/tabRecovery'
+import { Theme, CLIHandler, BootstrapData, TabContextMenuItemProvider, TabRecoveryProvider, HotkeyProvider, ConfigProvider } from './api'
 
 import { AppService } from './services/app.service'
 import { ConfigService } from './services/config.service'
@@ -115,6 +110,10 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
     }
 }
 
+export function getBootstrapData (): BootstrapData {
+    return (window as any).bootstrapData
+}
+
 export { AppRootComponent as bootstrap }
 export * from './api'
 

+ 5 - 0
terminus-local/src/session.ts

@@ -1,6 +1,7 @@
 import * as psNode from 'ps-node'
 import * as fs from 'mz/fs'
 import * as os from 'os'
+import { getBootstrapData } from 'terminus-core'
 import { BaseSession } from 'terminus-terminal'
 import { ipcRenderer } from 'electron'
 import { getWorkingDirectoryFromPID } from 'native-process-working-directory'
@@ -115,6 +116,10 @@ export class Session extends BaseSession {
                 ...this.config.store.terminal.environment || {},
             }
 
+            if (process.platform === 'win32') {
+                env.COMSPEC = getBootstrapData().executable
+            }
+
             delete env['']
 
             if (process.platform === 'darwin' && !process.env.LC_ALL) {