Skip to content

Commit 2eb9187

Browse files
committed
Fix Electron interception when bundled
1 parent 05fbbfa commit 2eb9187

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/interceptors/electron.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as _ from 'lodash';
22
import { spawn } from 'child_process';
33
import * as util from 'util';
4+
import * as path from 'path';
45
import * as fs from 'fs';
56

67
import { getPortPromise as getPort } from 'portfinder';
@@ -11,7 +12,7 @@ import { Interceptor } from '.';
1112

1213
import { HtkConfig } from '../config';
1314
import { delay } from '../util';
14-
import { getTerminalEnvVars } from './terminal/terminal-env-overrides';
15+
import { getTerminalEnvVars, OVERRIDES_DIR } from './terminal/terminal-env-overrides';
1516
import { reportError, addBreadcrumb } from '../error-tracking';
1617
import { findExecutableInApp } from '@httptoolkit/osx-find-executable';
1718

@@ -24,7 +25,7 @@ const isAppBundle = (path: string) => {
2425

2526
export class ElectronInterceptor implements Interceptor {
2627
readonly id = 'electron';
27-
readonly version = '1.0.0';
28+
readonly version = '1.0.1';
2829

2930
private debugClients: {
3031
[port: string]: Array<ChromeRemoteInterface.CdpClient>
@@ -98,8 +99,7 @@ export class ElectronInterceptor implements Interceptor {
9899
// Inside the Electron process, load our electron-intercepting JS.
99100
const injectionResult = await debugClient.Debugger.evaluateOnCallFrame({
100101
expression: `require("${
101-
// Need to escape slashes to ensure this works on Windows (where all paths have backslashes)
102-
require.resolve('../../overrides/js/prepend-electron.js').replace(/\\/g, '\\\\')
102+
path.join(OVERRIDES_DIR, 'js', 'prepend-electron.js')
103103
}")({
104104
newlineEncodedCertData: "${(await this.certData).replace(/\r\n|\r|\n/g, '\\n')}",
105105
spkiFingerprint: "${generateSPKIFingerprint(await this.certData)}"

src/interceptors/terminal/terminal-env-overrides.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { HttpsPathOptions } from 'mockttp/dist/util/tls';
44

55
const PATH_VAR_SEPARATOR = process.platform === 'win32' ? ';' : ':';
66

7-
const OVERRIDES_DIR = path.join(
7+
export const OVERRIDES_DIR = path.join(
88
process.env.HTK_IS_BUNDLED
99
? path.join(__dirname, '..')
1010
: path.join(__dirname, '..', '..', '..'),

test/integration-test.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ describe('Integration test', function () {
169169
"id": "electron",
170170
"isActivable": true,
171171
"isActive": false,
172-
"version": "1.0.0"
172+
"version": "1.0.1"
173173
}
174174
]);
175175
});

0 commit comments

Comments
 (0)