Skip to content

Commit d8b9379

Browse files
committed
Include the detected terminal in error reports
1 parent 29a71c5 commit d8b9379

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/interceptors/terminal/fresh-terminal-interceptor.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const findOsxExecutable = util.promisify(findOsxExecutableCb);
1212

1313
import { Interceptor } from '..';
1414
import { HtkConfig } from '../../config';
15-
import { reportError } from '../../error-tracking';
15+
import { reportError, addBreadcrumb } from '../../error-tracking';
1616
import { OVERRIDE_BIN_PATH, getTerminalEnvVars } from './terminal-env-overrides';
1717

1818
const checkAccess = util.promisify(fs.access);
@@ -58,10 +58,19 @@ const spawnAndCollectOutput = (command: string, args: string[] = []): Promise<{
5858
};
5959

6060
const getTerminalCommand = _.memoize(async (): Promise<SpawnArgs | null> => {
61-
if (process.platform === 'win32') return getWindowsTerminalCommand();
62-
else if (process.platform === 'darwin') return getOSXTerminalCommand();
63-
else if (process.platform === 'linux') return getLinuxTerminalCommand();
64-
else return null;
61+
let result: Promise<SpawnArgs | null>;
62+
63+
if (process.platform === 'win32') result = getWindowsTerminalCommand();
64+
else if (process.platform === 'darwin') result = getOSXTerminalCommand();
65+
else if (process.platform === 'linux') result = getLinuxTerminalCommand();
66+
else result = Promise.resolve(null);
67+
68+
result.then((terminal) => {
69+
if (terminal) addBreadcrumb('Found terminal', { data: { terminal } });
70+
else reportError('No terminal could be detected');
71+
});
72+
73+
return result;
6574
});
6675

6776
const getWindowsTerminalCommand = async (): Promise<SpawnArgs | null> => {
@@ -367,11 +376,6 @@ const resetShellStartupScripts = () => {
367376

368377
const terminals: _.Dictionary<ChildProcess[] | undefined> = {}
369378

370-
// Memoize this report: i.e. send it only once
371-
const reportNoTerminal = _.memoize(() => {
372-
reportError('No terminal could be detected');
373-
});
374-
375379
export class TerminalInterceptor implements Interceptor {
376380

377381
id = 'fresh-terminal';
@@ -380,9 +384,7 @@ export class TerminalInterceptor implements Interceptor {
380384
constructor(private config: HtkConfig) { }
381385

382386
async isActivable(): Promise<boolean> {
383-
const terminalAvailable = !!(await getTerminalCommand());
384-
if (!terminalAvailable) reportNoTerminal();
385-
return terminalAvailable;
387+
return !!(await getTerminalCommand());
386388
}
387389

388390
isActive(proxyPort: number | string): boolean {

0 commit comments

Comments
 (0)