Skip to content

Commit fc6f8dd

Browse files
committed
Recreate webextension config dir if necessary
1 parent cf53186 commit fc6f8dd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/webextension.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import * as path from 'path';
22
import { OVERRIDES_DIR } from './interceptors/terminal/terminal-env-overrides';
33

4-
import { deleteFile, writeFile } from "./util/fs";
4+
import { deleteFile, mkDir, writeFile } from "./util/fs";
55

66
export const WEBEXTENSION_PATH = path.join(OVERRIDES_DIR, 'webextension');
7+
const WEBEXTENSION_CONFIG_PATH = path.join(WEBEXTENSION_PATH, 'config');
78

89
interface WebExtensionConfig { // Should match config in the WebExtension itself
910
mockRtc: {
@@ -16,7 +17,7 @@ const getConfigKey = (proxyPort: number) =>
1617
`127_0_0_1.${proxyPort}`; // Filename-safe proxy address
1718

1819
const getConfigPath = (proxyPort: number) =>
19-
path.join(WEBEXTENSION_PATH, 'config', getConfigKey(proxyPort));
20+
path.join(WEBEXTENSION_CONFIG_PATH, getConfigKey(proxyPort));
2021

2122
export function clearWebExtensionConfig(httpProxyPort: number) {
2223
return deleteFile(getConfigPath(httpProxyPort))
@@ -42,5 +43,6 @@ export async function updateWebExtensionConfig(
4243
}
4344

4445
async function writeConfig(proxyPort: number, config: WebExtensionConfig) {
46+
await mkDir(WEBEXTENSION_CONFIG_PATH).catch(() => {}); // Make sure the config dir exists
4547
return writeFile(getConfigPath(proxyPort), JSON.stringify(config));
4648
}

0 commit comments

Comments
 (0)