Skip to content

Commit

Permalink
Iterate
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Telatynski <[email protected]>
  • Loading branch information
t3chguy committed Oct 16, 2024
1 parent b880ea6 commit 31d8a15
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 36 deletions.
6 changes: 5 additions & 1 deletion hak/keytar/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export default async function buildKeytar(hakEnv: HakEnv, moduleInfo: Dependency
},
);
proc.on("exit", (code) => {
code ? reject(code) : resolve();
if (code) {
reject(code);
} else {
resolve();
}
});
});
}
12 changes: 10 additions & 2 deletions hak/matrix-seshat/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Prom
stdio: "inherit",
});
proc.on("exit", (code) => {
code ? reject(code) : resolve();
if (code) {
reject(code);
} else {
resolve();
}
});
});

Expand All @@ -42,7 +46,11 @@ export default async function (hakEnv: HakEnv, moduleInfo: DependencyInfo): Prom
stdio: "inherit",
});
proc.on("exit", (code) => {
code ? reject(code) : resolve();
if (code) {
reject(code);
} else {
resolve();
}
});
});
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"@electron/fuses": "^1.7.0",
"@mapbox/node-pre-gyp": "^1.0.11",
"@playwright/test": "1.48.0",
"@stylistic/eslint-plugin": "^2.9.0",
"@types/auto-launch": "^5.0.1",
"@types/counterpart": "^0.18.1",
"@types/minimist": "^1.2.1",
Expand All @@ -104,7 +105,7 @@
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-matrix-org": "^1.0.0",
"eslint-plugin-matrix-org": "^2.0.1",
"eslint-plugin-unicorn": "^56.0.0",
"glob": "^11.0.0",
"knip": "^5.0.0",
Expand Down
10 changes: 5 additions & 5 deletions scripts/fetch-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function downloadToFile(url: string, filename: string): Promise<void> {
console.error(e);
try {
await fs.unlink(filename);
} catch (_) {}
} catch {}
throw e;
}
}
Expand Down Expand Up @@ -150,14 +150,14 @@ async function main(): Promise<number | undefined> {
await fs.opendir(expectedDeployDir);
console.log(expectedDeployDir + "already exists");
haveDeploy = true;
} catch (e) {}
} catch {}

if (!haveDeploy) {
const outPath = path.join(pkgDir, filename);
try {
await fs.stat(outPath);
console.log("Already have " + filename + ": not redownloading");
} catch (e) {
} catch {
try {
await downloadToFile(url, outPath);
} catch (e) {
Expand All @@ -170,7 +170,7 @@ async function main(): Promise<number | undefined> {
try {
await fs.stat(outPath + ".asc");
console.log("Already have " + filename + ".asc: not redownloading");
} catch (e) {
} catch {
try {
await downloadToFile(url + ".asc", outPath + ".asc");
} catch (e) {
Expand Down Expand Up @@ -206,7 +206,7 @@ async function main(): Promise<number | undefined> {
await fs.stat(ASAR_PATH);
console.log(ASAR_PATH + " already present: removing");
await fs.unlink(ASAR_PATH);
} catch (e) {}
} catch {}

if (cfgDir.length) {
const configJsonSource = path.join(cfgDir, "config.json");
Expand Down
8 changes: 6 additions & 2 deletions scripts/hak/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default async function fetch(hakEnv: HakEnv, moduleInfo: DependencyInfo):
try {
const stats = await fsProm.stat(moduleInfo.moduleBuildDir);
haveModuleBuildDir = stats.isDirectory();
} catch (e) {
} catch {
haveModuleBuildDir = false;
}

Expand All @@ -41,7 +41,11 @@ export default async function fetch(hakEnv: HakEnv, moduleInfo: DependencyInfo):
shell: hakEnv.isWin(),
});
proc.on("exit", (code) => {
code ? reject(code) : resolve();
if (code) {
reject(code);
} else {
resolve();
}
});
});

Expand Down
6 changes: 4 additions & 2 deletions scripts/hak/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ async function main(): Promise<void> {
const prefix = path.join(__dirname, "..", "..");
let packageJson;
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
packageJson = require(path.join(prefix, "package.json"));
} catch (e) {
} catch {
console.error("Can't find a package.json!");
process.exit(1);
}
Expand Down Expand Up @@ -69,8 +70,9 @@ async function main(): Promise<void> {
const hakJsonPath = path.join(prefix, "hak", dep, "hak.json");
let hakJson: Record<string, any>;
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
hakJson = await require(hakJsonPath);
} catch (e) {
} catch {
console.error("No hak.json found for " + dep + ".");
console.log("Expecting " + hakJsonPath);
process.exit(1);
Expand Down
14 changes: 11 additions & 3 deletions scripts/hak/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default async function link(hakEnv: HakEnv, moduleInfo: DependencyInfo):
// Also we do this for each module which is unnecessary, but meh.
try {
await fsProm.stat(yarnrc);
} catch (e) {
} catch {
await fsProm.writeFile(
yarnrc,
// XXX: 1. This must be absolute, as yarn will resolve link directories
Expand All @@ -50,7 +50,11 @@ export default async function link(hakEnv: HakEnv, moduleInfo: DependencyInfo):
shell: hakEnv.isWin(),
});
proc.on("exit", (code) => {
code ? reject(code) : resolve();
if (code) {
reject(code);
} else {
resolve();
}
});
});

Expand All @@ -63,7 +67,11 @@ export default async function link(hakEnv: HakEnv, moduleInfo: DependencyInfo):
shell: hakEnv.isWin(),
});
proc.on("exit", (code) => {
code ? reject(code) : resolve();
if (code) {
reject(code);
} else {
resolve();
}
});
});
}
2 changes: 1 addition & 1 deletion scripts/set-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as childProcess from "child_process";
export async function versionFromAsar(): Promise<string> {
try {
await fs.stat("webapp.asar");
} catch (e) {
} catch {
throw new Error("No 'webapp.asar' found. Run 'yarn run fetch'");
}

Expand Down
6 changes: 3 additions & 3 deletions src/electron-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async function tryPaths(name: string, root: string, rawPaths: string[]): Promise
try {
await afs.stat(p);
return p + "/";
} catch (e) {}
} catch {}
}
console.log(`Couldn't find ${name} files in any of: `);
for (const p of paths) {
Expand Down Expand Up @@ -137,7 +137,7 @@ async function loadConfig(): Promise<void> {

try {
global.vectorConfig = loadJsonFile(asarPath, "config.json");
} catch (e) {
} catch {
// it would be nice to check the error code here and bail if the config
// is unparsable, but we get MODULE_NOT_FOUND in the case of a missing
// file or invalid json, so node is just very unhelpful.
Expand Down Expand Up @@ -367,7 +367,7 @@ app.on("ready", async () => {

if (argv["devtools"]) {
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { default: installExt, REACT_DEVELOPER_TOOLS, REACT_PERF } = require("electron-devtools-installer");
installExt(REACT_DEVELOPER_TOOLS)
.then((name: string) => console.log(`Added Extension: ${name}`))
Expand Down
6 changes: 3 additions & 3 deletions src/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ ipcMain.on("ipcCall", async function (_ev: IpcMainEvent, payload) {
if (ret === null) {
ret = await keytar?.getPassword("riot.im", `${args[0]}|${args[1]}`);
}
} catch (e) {
} catch {
// if an error is thrown (e.g. keytar can't connect to the keychain),
// then return null, which means the default pickle key will be used
ret = null;
Expand All @@ -159,7 +159,7 @@ ipcMain.on("ipcCall", async function (_ev: IpcMainEvent, payload) {
const pickleKey = await randomArray(32);
await keytar?.setPassword("element.io", `${args[0]}|${args[1]}`, pickleKey);
ret = pickleKey;
} catch (e) {
} catch {
ret = null;
}
break;
Expand All @@ -170,7 +170,7 @@ ipcMain.on("ipcCall", async function (_ev: IpcMainEvent, payload) {
// migrate from riot.im (remove once we think there will no longer be
// logins from the time of riot.im)
await keytar?.deletePassword("riot.im", `${args[0]}|${args[1]}`);
} catch (e) {}
} catch {}
break;
case "getDesktopCapturerSources":
ret = (await desktopCapturer.getSources(args[0])).map((source) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/keytar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type * as Keytar from "keytar"; // Hak dependency type

let keytar: typeof Keytar | undefined;
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
keytar = require("keytar");
} catch (e) {
if ((<NodeJS.ErrnoException>e).code === "MODULE_NOT_FOUND") {
Expand Down
2 changes: 1 addition & 1 deletion src/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function readStore(): Record<string, string> {
const s = fs.readFileSync(storePath, { encoding: "utf8" });
const o = JSON.parse(s);
return typeof o === "object" ? o : {};
} catch (e) {
} catch {
return {};
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/seshat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let SeshatRecovery: typeof SeshatRecoveryType;
let ReindexError: typeof ReindexErrorType;

try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const seshatModule = require("matrix-seshat");
Seshat = seshatModule.Seshat;
SeshatRecovery = seshatModule.SeshatRecovery;
Expand Down Expand Up @@ -118,7 +118,7 @@ ipcMain.on("seshat", async function (_ev: IpcMainEvent, payload): Promise<void>

try {
await deleteContents(eventStorePath);
} catch (e) {}
} catch {}
} else {
await recoveryIndex.reindex();
}
Expand Down Expand Up @@ -149,7 +149,7 @@ ipcMain.on("seshat", async function (_ev: IpcMainEvent, payload): Promise<void>
case "deleteEventIndex": {
try {
await deleteContents(eventStorePath);
} catch (e) {}
} catch {}
break;
}

Expand Down Expand Up @@ -264,7 +264,7 @@ ipcMain.on("seshat", async function (_ev: IpcMainEvent, payload): Promise<void>
else {
try {
ret = await eventIndex.loadCheckpoints();
} catch (e) {
} catch {
ret = [];
}
}
Expand Down
44 changes: 37 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,17 @@
ignore "^5.1.8"
p-map "^4.0.0"

"@stylistic/eslint-plugin@^2.9.0":
version "2.9.0"
resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin/-/eslint-plugin-2.9.0.tgz#5ab3326303915e020ddaf39154290e2800a84bcd"
integrity sha512-OrDyFAYjBT61122MIY1a3SfEgy3YCMgt2vL4eoPmvTwDBwyQhAXurxNQznlRD/jESNfYWfID8Ej+31LljvF7Xg==
dependencies:
"@typescript-eslint/utils" "^8.8.0"
eslint-visitor-keys "^4.1.0"
espree "^10.2.0"
estraverse "^5.3.0"
picomatch "^4.0.2"

"@szmarczak/http-timer@^4.0.5":
version "4.0.6"
resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807"
Expand Down Expand Up @@ -2177,7 +2188,7 @@
semver "^7.6.0"
ts-api-utils "^1.3.0"

"@typescript-eslint/[email protected]":
"@typescript-eslint/[email protected]", "@typescript-eslint/utils@^8.8.0":
version "8.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-8.9.0.tgz#748bbe3ea5bee526d9786d9405cf1b0df081c299"
integrity sha512-PKgMmaSo/Yg/F7kIZvrgrWa1+Vwn036CdNUvYFEkYbPwOH4i8xvkaRlu148W3vtheWK9ckKRIz7PBP5oUlkrvQ==
Expand Down Expand Up @@ -2242,6 +2253,11 @@ acorn@^8.11.0, acorn@^8.4.1, acorn@^8.8.2, acorn@^8.9.0:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.12.1.tgz#71616bdccbe25e27a54439e0046e89ca76df2248"
integrity sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==

acorn@^8.12.0:
version "8.13.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.13.0.tgz#2a30d670818ad16ddd6a35d3842dacec9e5d7ca3"
integrity sha512-8zSiw54Oxrdym50NlZ9sUusyO1Z1ZchgRLWRaK6c86XJFClyCgFKetdowBg5bKxyp/u+CDBJG4Mpp0m3HLZl9w==

agent-base@6, agent-base@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77"
Expand Down Expand Up @@ -3625,10 +3641,10 @@ eslint-plugin-import@^2.25.4:
semver "^6.3.1"
tsconfig-paths "^3.15.0"

eslint-plugin-matrix-org@^1.0.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-matrix-org/-/eslint-plugin-matrix-org-1.2.1.tgz#76d1505daa93fb99ba4156008b9b32f57682c9b1"
integrity sha512-A3cDjhG7RHwfCS8o3bOip8hSCsxtmgk2ahvqE5v/Ic2kPEZxixY6w8zLj7hFGsrRmPSEpLWqkVLt8uvQBapiQA==
eslint-plugin-matrix-org@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-matrix-org/-/eslint-plugin-matrix-org-2.0.1.tgz#d6fdefa1d31e6f963cd1f5c804b54ff4c30eadc0"
integrity sha512-BVZ15OstnePWujwj3z96IQJ8iqbqq4gin3psD5cvugPC39bpyvgKW9DfHptDN/SZYYuSvNMaQAtAtboc2kqAxw==

eslint-plugin-unicorn@^56.0.0:
version "56.0.0"
Expand Down Expand Up @@ -3665,6 +3681,11 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800"
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==

eslint-visitor-keys@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.1.0.tgz#1f785cc5e81eb7534523d85922248232077d2f8c"
integrity sha512-Q7lok0mqMUSf5a/AdAZkA5a/gHcO6snwQClVNNvFKCAVlxXucdU8pKydU5ZVZjBx5xr37vGbFFWtLQYreLzrZg==

eslint@^8.26.0:
version "8.57.1"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.1.tgz#7df109654aba7e3bbe5c8eae533c5e461d3c6ca9"
Expand Down Expand Up @@ -3709,6 +3730,15 @@ eslint@^8.26.0:
strip-ansi "^6.0.1"
text-table "^0.2.0"

espree@^10.2.0:
version "10.2.0"
resolved "https://registry.yarnpkg.com/espree/-/espree-10.2.0.tgz#f4bcead9e05b0615c968e85f83816bc386a45df6"
integrity sha512-upbkBJbckcCNBDBDXEbuhjbP68n+scUd3k/U2EkyM9nw+I/jPiL4cLF/Al06CF96wRltFda16sxDFrxsI1v0/g==
dependencies:
acorn "^8.12.0"
acorn-jsx "^5.3.2"
eslint-visitor-keys "^4.1.0"

espree@^9.6.0, espree@^9.6.1:
version "9.6.1"
resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f"
Expand All @@ -3732,7 +3762,7 @@ esrecurse@^4.3.0:
dependencies:
estraverse "^5.2.0"

estraverse@^5.1.0, estraverse@^5.2.0:
estraverse@^5.1.0, estraverse@^5.2.0, estraverse@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123"
integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==
Expand Down Expand Up @@ -5831,7 +5861,7 @@ picomatch@^2.3.1:
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==

picomatch@^4.0.1:
picomatch@^4.0.1, picomatch@^4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.2.tgz#77c742931e8f3b8820946c76cd0c1f13730d1dab"
integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==
Expand Down

0 comments on commit 31d8a15

Please sign in to comment.