Skip to content

Commit

Permalink
fix(windows): drop pst not working
Browse files Browse the repository at this point in the history
  • Loading branch information
lsagetlethias committed Oct 13, 2022
1 parent c79b2e5 commit 9eedac1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ jobs:
- name: Setup Node
uses: ./.github/actions/setup-node
- name: Yarn install
env:
npm_config_build_from_source: true
run: yarn --frozen-lockfile --perfer-offline
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
Expand Down
10 changes: 10 additions & 0 deletions scripts/replaceForChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ replace({
silent: true,
});

const appIdReplacement = `"appId": "fr.gouv.social.fabrique.archifiltre.$1-${channel}"`;
console.log("[ReplaceForChannel] Replacing app id with", appIdReplacement);
replace({
paths: [packageJsonPath],
recursive: false,
regex: /"appId": "fr\.gouv\.social\.fabrique\.archifiltre\.(.+)"/g,
replacement: appIdReplacement,
silent: true,
});

const iconIcnsReplacement = `"icon": "./electron/build/icon_${channel}.icns"`;
console.log(
"[ReplaceForChannel] Replacing ICNS icon with",
Expand Down
14 changes: 12 additions & 2 deletions src/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface WorkerConfig {
IS_MAIN: boolean;
IS_PACKAGED: boolean;
IS_TEST: boolean;
IS_WIN: boolean;
PRODUCT_CHANNEL: "beta" | "next" | "stable";
STATIC_PATH: string;
}
Expand All @@ -47,6 +48,7 @@ export const IS_DEV =
(process.env.NODE_ENV !== "production" && !IS_TEST);
export const IS_E2E = localWorkerConfig.IS_E2E ?? !!process.env.E2E;
export const IS_MAC = localWorkerConfig.IS_MAC ?? process.platform === "darwin";
export const IS_WIN = localWorkerConfig.IS_WIN ?? process.platform === "win32";
const IS_PACKAGE_EVENT = "config.IS_PACKAGED";
const APP_CACHE_EVENT = "config.APP_CACHE";
if (IS_MAIN && !IS_WORKER) {
Expand All @@ -61,7 +63,12 @@ if (IS_MAIN && !IS_WORKER) {
if (IS_DEV && IS_MAIN && !IS_WORKER) {
app.setName(`${name}-dev`);
app.setPath("appData", path.resolve(__dirname, "../../electron/.appData/"));
app.setPath("cache", path.resolve(__dirname, "../../electron/.appCache/"));
if (!IS_WIN) {
app.setPath(
"cache",
path.resolve(__dirname, "../../electron/.appCache/")
);
}
}

export const IS_PACKAGED = (): boolean => {
Expand All @@ -74,7 +81,9 @@ export const IS_PACKAGED = (): boolean => {
export const APP_CACHE = (): string => {
if (IS_WORKER) return localWorkerConfig.APP_CACHE!;
if (IS_MAIN) {
return path.resolve(app.getPath("cache"), name);
return IS_WIN
? path.resolve(app.getPath("userData"), "Cache")
: path.resolve(app.getPath("cache"), app.getName());
} else return ipcRenderer.sendSync(APP_CACHE_EVENT) as string;
};

Expand All @@ -98,6 +107,7 @@ export const workerConfig: WorkerConfig = {
IS_MAIN,
IS_PACKAGED: IS_PACKAGED(),
IS_TEST,
IS_WIN,
PRODUCT_CHANNEL,
STATIC_PATH,
};
3 changes: 3 additions & 0 deletions tests/integration/mock/electron.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import path from "path";

process.env.NODE_ENV = "test-jest";

jest.mock(
"electron",
() => {
Expand All @@ -9,6 +11,7 @@ jest.mock(
return {
app: {
getLocale: () => "fr-FR",
getName: () => `archifiltre-mails-test`,
getPath: (p: string) =>
path.resolve(__dirname, `../__app_getPath__/${p}`),
},
Expand Down

0 comments on commit 9eedac1

Please sign in to comment.