Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 77fe65b

Browse files
starpitk8s-ci-robot
authored andcommitted
fix: restore pure headless operation
1 parent 971b4ea commit 77fe65b

File tree

5 files changed

+54
-18
lines changed

5 files changed

+54
-18
lines changed

packages/core/src/main/headless-pretty-print.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const debug = Debug('main/headless-pretty-print')
1919
debug('loading')
2020

2121
import { Writable } from 'stream'
22-
import * as colors from 'colors/safe'
22+
import colors from 'colors/safe'
2323

2424
import ElementMimic from '../util/element-mimic'
2525
import { isTable, Row } from '../webapp/models/table'

packages/core/src/main/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function getPrefsFromEnv(env: typeof process.env, defaultPrefs: ISubwindowPrefs)
3636
*/
3737
export const main = async (argv: string[], env = process.env, execOptions?: ExecOptions) => {
3838
const N = argv.length
39-
const isRunningHeadless = argv[N - 3] === 'bash' && argv[N - 2] === 'websocket'
39+
const isRunningHeadless = !!process.env.KUI_HEADLESS || (argv[N - 3] === 'bash' && argv[N - 2] === 'websocket')
4040

4141
if (!isRunningHeadless) {
4242
// then spawn the electron graphics

packages/core/src/repl/exec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import Debug from 'debug'
2525
const debug = Debug('core/repl')
26+
const debugCommandErrors = Debug('core/repl/errors')
2627

2728
import { v4 as uuid } from 'uuid'
2829
import encodeComponent from './encode'
@@ -456,6 +457,7 @@ class InProcessExecutor implements Executor {
456457
return response
457458
})
458459
} catch (err) {
460+
debugCommandErrors(err)
459461
evaluator.error(command, tab, execType, err)
460462
if (execType === ExecType.Nested) {
461463
throw err

plugins/plugin-bash-like/fs/src/lib/ls.ts

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ import { localFilepath } from './usage-helpers'
3434
const dateFormatter = speedDate('MMM DD HH:mm')
3535
const strings = i18n('plugin-bash-like')
3636

37+
/** Heading names */
38+
const Key = {
39+
UID: 'UID',
40+
GID: 'GID',
41+
Size: 'Size',
42+
User: 'User',
43+
Group: 'Group',
44+
Permissions: 'Permissions',
45+
LastModified: 'Last Modified'
46+
}
47+
3748
/**
3849
* Mimic ls -lh
3950
*
@@ -161,17 +172,23 @@ function attrs(
161172
// const language = withLanguage(args.execOptions).language
162173

163174
const wide = args.parsedOptions.l
164-
const perms = wide && hasPermissions ? [{ value: formatPermissions(entry), outerCSS: outerCSSSecondary }] : []
165-
const uid = wide && hasUid ? [{ value: formatUid(entry), outerCSS: outerCSSSecondary, css: cssSecondary }] : []
166-
const gid = wide && hasGid ? [{ value: formatGid(entry), outerCSS: outerCSSSecondary, css: cssSecondary }] : []
175+
const perms =
176+
wide && hasPermissions
177+
? [{ key: Key.Permissions, value: formatPermissions(entry), outerCSS: outerCSSSecondary }]
178+
: []
179+
const uid =
180+
wide && hasUid ? [{ key: Key.UID, value: formatUid(entry), outerCSS: outerCSSSecondary, css: cssSecondary }] : []
181+
const gid =
182+
wide && hasGid ? [{ key: Key.GID, value: formatGid(entry), outerCSS: outerCSSSecondary, css: cssSecondary }] : []
167183
const size =
168184
wide && hasSize
169-
? [{ value: prettyBytes(entry.stats.size).replace(/\s/g, ''), outerCSS: '', css: 'yellow-text' }]
185+
? [{ key: Key.Size, value: prettyBytes(entry.stats.size).replace(/\s/g, ''), outerCSS: '', css: 'yellow-text' }]
170186
: []
171187
const lastMod =
172188
wide && hasMtime
173189
? [
174190
{
191+
key: Key.LastModified,
175192
value: prettyTime(entry.stats.mtimeMs),
176193
outerCSS: outerCSSLesser,
177194
css: `${cssLesser} ${cssSecondary} pre-wrap sub-text`
@@ -209,11 +226,15 @@ function toTable(entries: GlobStats[], args: Arguments<LsOptions>): Table {
209226
}))
210227

211228
const wide = args.parsedOptions.l
212-
const perms = wide && hasPermissions ? [{ value: 'Permissions', outerCSS: outerCSSSecondary }] : []
213-
const uid = wide && hasUid ? [{ value: 'User', outerCSS: outerCSSSecondary }] : []
214-
const gid = wide && hasGid ? [{ value: 'Group', outerCSS: outerCSSSecondary }] : []
215-
const size = wide && hasSize ? [{ value: 'Size', outerCSS: '' }] : []
216-
const lastMod = wide && hasMtime ? [{ value: 'Last Modified', outerCSS: outerCSSLesser, css: cssLesser }] : []
229+
const perms =
230+
wide && hasPermissions ? [{ key: Key.Permissions, value: 'Permissions', outerCSS: outerCSSSecondary }] : []
231+
const uid = wide && hasUid ? [{ key: Key.User, value: 'User', outerCSS: outerCSSSecondary }] : []
232+
const gid = wide && hasGid ? [{ key: Key.Group, value: 'Group', outerCSS: outerCSSSecondary }] : []
233+
const size = wide && hasSize ? [{ key: Key.Size, value: 'Size', outerCSS: '' }] : []
234+
const lastMod =
235+
wide && hasMtime
236+
? [{ key: Key.LastModified, value: 'Last Modified', outerCSS: outerCSSLesser, css: cssLesser }]
237+
: []
217238

218239
const header = {
219240
name: 'Name',

plugins/plugin-bash-like/fs/src/vfs/index.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,32 @@ async function mountAll({ REPL }: Pick<Arguments, 'REPL'>, vfsFn: VFSProducingFu
179179
*/
180180
export async function mount(vfs: VFS | VFSProducingFunction) {
181181
if (typeof vfs !== 'function') {
182-
_mount(vfs)
182+
await _mount(vfs)
183183
} else {
184184
const tab = getCurrentTab()
185185
if (!tab) {
186-
let debounce = false
187-
eventBus.on('/tab/new', tab => {
188-
if (!debounce) {
189-
debounce = true
190-
mountAll(tab, vfs)
186+
return new Promise((resolve, reject) => {
187+
try {
188+
let debounce = false
189+
eventBus.on('/tab/new', async tab => {
190+
try {
191+
if (!debounce) {
192+
debounce = true
193+
await mountAll(tab, vfs)
194+
resolve(undefined)
195+
}
196+
} catch (err) {
197+
console.error('Error in mount 1', err)
198+
reject(err)
199+
}
200+
})
201+
} catch (err) {
202+
console.error('Error in mount 2', err)
203+
reject(err)
191204
}
192205
})
193206
} else {
194-
mountAll(tab, vfs)
207+
await mountAll(tab, vfs)
195208
}
196209
}
197210
}

0 commit comments

Comments
 (0)