Skip to content

Commit

Permalink
upgrade @electron 8.0.1 => 9.0.0-beta.5
Browse files Browse the repository at this point in the history
* upgrade is now possible since electron #22242 blocker got resolved
  • Loading branch information
vladimiry committed Mar 5, 2020
1 parent 36d1a60 commit c85062c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -222,7 +222,7 @@
"cross-env": "7.0.1",
"css-loader": "3.4.2",
"cssnano": "4.1.10",
"electron": "8.0.3",
"electron": "9.0.0-beta.5",
"electron-builder": "22.3.6",
"escape-string-regexp": "2.0.0",
"eslint": "6.8.0",
Expand Down
24 changes: 16 additions & 8 deletions src/electron-main/__test__/api/index.spec.ts
Expand Up @@ -311,7 +311,7 @@ const tests: Record<keyof TestContext["endpoints"], (t: ExecutionContext<TestCon
},

openExternal: async (t) => {
const openExternalSpy: sinon.SinonSpy = t.context.mocks.electron.shell.openExternalSpy;
const openExternalSpy = t.context.mocks.electron.shell.openExternalSpy;
const action = t.context.endpoints.openExternal;

const forbiddenUrls = [
Expand All @@ -333,15 +333,15 @@ const tests: Record<keyof TestContext["endpoints"], (t: ExecutionContext<TestCon
];
for (const url of allowedUrls) {
// tslint:disable-next-line:await-promise
await t.notThrowsAsync(action({url: url as string}));
t.true(openExternalSpy.calledWith(url), `electron.shell.openExternal.calledWith("${url}")`);
await t.notThrowsAsync(action({url}));
t.true(openExternalSpy.calledWith(url), `electron.shell.openPath.calledWith("${url}")`);
}
},

openSettingsFolder: async (t) => {
const openItemSpy: sinon.SinonSpy = t.context.mocks.electron.shell.openItem;
const openPathSpy = t.context.mocks.electron.shell.openPathSpy;
await t.context.endpoints.openSettingsFolder();
t.true(openItemSpy.alwaysCalledWith(t.context.ctx.locations.userDataDir));
t.true(openPathSpy.alwaysCalledWith(t.context.ctx.locations.userDataDir));
},

patchBaseConfig: async (t) => {
Expand Down Expand Up @@ -464,6 +464,7 @@ async function readConfigAndSettings(
}

async function buildMocks() {
const openPathSpy = sinon.spy();
const openExternalSpy = sinon.spy();

return {
Expand Down Expand Up @@ -521,21 +522,28 @@ async function buildMocks() {
removeListener: sinon.spy(),
},
shell: {
openPathSpy,
openPath: await (async () => {
const openPath: (typeof import("electron"))["shell"]["openPath"] = async (url) => {
openPathSpy(url);
return "";
};
return openPath;
})(),
openExternalSpy,
openExternal: await (async () => {
const openExternal: (typeof import("electron"))["shell"]["openExternal"] = async (url) => {
openExternalSpy(url);
};
return openExternal;
})(),
openItem: sinon.spy(),
},
nativeImage: {
createFromPath: sinon.stub().returns({toPNG: sinon.spy}),
createFromBuffer: sinon.stub(),
},
} as any,
};
},
} as const;
}

test.beforeEach(async (t) => {
Expand Down
6 changes: 5 additions & 1 deletion src/electron-main/api/endpoints-builders/general.ts
Expand Up @@ -50,7 +50,11 @@ export async function buildEndpoints(
},

async openSettingsFolder() {
shell.openItem(ctx.locations.userDataDir);
const errorMessage = await shell.openPath(ctx.locations.userDataDir);

if (errorMessage) {
throw new Error(errorMessage);
}
},

async quit() {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -4138,10 +4138,10 @@ electron-unhandled@3.0.2:
ensure-error "^2.0.0"
lodash.debounce "^4.0.8"

electron@8.0.3:
version "8.0.3"
resolved "https://registry.yarnpkg.com/electron/-/electron-8.0.3.tgz#e0488baaa69291e26dc981ea9bc75b5da92c5c88"
integrity sha512-lr/tTr9cBzocREmL8r/P3WKnGqpKeaMFZjNVXDGd3npxwnJVUd7SHQW7LZIhZ1W2XoU3uBwTYbyH43iCIElsqw==
electron@9.0.0-beta.5:
version "9.0.0-beta.5"
resolved "https://registry.yarnpkg.com/electron/-/electron-9.0.0-beta.5.tgz#f553e76523dce1f5a9f8ed1bc0cbed7d267fecbe"
integrity sha512-yRStYrxMxNlzfVpwXN+m6O5iRooA+2aVcxi7iJlcNPoGS2ooFvESIbQxog3BJ1o8PAJmx/Zk6sSIsYNfL1H50A==
dependencies:
"@electron/get" "^1.0.1"
"@types/node" "^12.0.12"
Expand Down

0 comments on commit c85062c

Please sign in to comment.