Remove use of __dirname from main process

This commit is contained in:
Fedor Indutny
2026-03-27 10:55:37 -07:00
committed by GitHub
parent 70f111e868
commit a048f83dbc
39 changed files with 222 additions and 337 deletions

View File

@@ -1,6 +1,7 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { join } from 'node:path';
import { assert } from 'chai';
import { stub } from 'sinon';
import * as LocaleMatcher from '@formatjs/intl-localematcher';
@@ -8,6 +9,8 @@ import { load, _getAvailableLocales } from '../../../app/locale.node.js';
import { FAKE_DEFAULT_LOCALE } from '../../../app/spell_check.main.js';
import { HourCyclePreference } from '../../types/I18N.std.js';
const rootDir = join(__dirname, '..', '..', '..');
describe('locale', async () => {
describe('load', () => {
it('resolves expected locales correctly', async () => {
@@ -26,6 +29,7 @@ describe('locale', async () => {
expectedLocale: string
) {
const actualLocale = await load({
rootDir,
hourCyclePreference: HourCyclePreference.UnknownPreference,
isPackaged: false,
localeDirectionTestingOverride: null,
@@ -150,7 +154,7 @@ describe('locale', async () => {
'VE',
];
const availableLocales = _getAvailableLocales();
const availableLocales = _getAvailableLocales(rootDir);
for (const locale of SINGLE_REGION_LOCALES) {
const { language } = new Intl.Locale(locale);

View File

@@ -1,6 +1,7 @@
// Copyright 2018 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { join } from 'node:path';
import { assert } from 'chai';
import { stub } from 'sinon';
import type { MenuItemConstructorOptions } from 'electron';
@@ -214,6 +215,7 @@ describe('createTemplate', () => {
};
const { i18n } = loadLocale({
rootDir: join(__dirname, '..', '..', '..'),
hourCyclePreference: HourCyclePreference.UnknownPreference,
isPackaged: false,
localeDirectionTestingOverride: null,

View File

@@ -9,14 +9,14 @@ import { tmpdir } from 'node:os';
import { strictAssert } from '../../util/assert.std.js';
import * as durations from '../../util/durations/index.std.js';
import { getGotOptions } from '../../updater/got.node.js';
import { getGotOptions } from '../../updater/got.main.js';
import {
computeDiff,
getBlockMapFileName,
prepareDownload,
isValidPreparedData,
download,
} from '../../updater/differential.node.js';
} from '../../updater/differential.main.js';
const FIXTURES = path.join(__dirname, '..', '..', '..', 'fixtures');
const CRLF = '\r\n';

View File

@@ -4,10 +4,12 @@
import { assert } from 'chai';
import * as Privacy from '../../util/privacy.node.js';
import { APP_ROOT_PATH } from '../../util/privacy.node.js';
Privacy.addSensitivePath('sensitive-path');
const APP_ROOT_PATH = __dirname;
Privacy.addSensitivePath(APP_ROOT_PATH);
describe('Privacy', () => {
describe('redactCardNumbers', () => {
it('should redact anything that looks like a credit card', () => {