Skip to content

Commit

Permalink
Use electron.remote.shell instead of electron.shell
Browse files Browse the repository at this point in the history
  • Loading branch information
confused-Techie committed Dec 16, 2024
1 parent a5fccfc commit 606b931
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions packages/tree-view/lib/tree-view.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const shell = require('electron').shell;
const remoteShell = require('electron').remote.shell;
const _ = require('underscore-plus');
const fs = require('fs-plus');
const { CompositeDisposable, Emitter } = require('atom');
Expand Down Expand Up @@ -822,7 +823,7 @@ class TreeView {
`Unable to show ${filePath} in ${this.getFileManagerName()}`
);
}
return shell.showItemInFolder(filePath);
return remoteShell.showItemInFolder(filePath);
}

showCurrentFileInFileManager() {
Expand All @@ -834,7 +835,7 @@ class TreeView {
`Unable to show ${filePath} in ${this.getFileManagerName()}`
);
}
return shell.showItemInFolder(filePath);
return remoteShell.showItemInFolder(filePath);
}

getFileManagerName() {
Expand Down
15 changes: 8 additions & 7 deletions packages/tree-view/spec/tree-view-package-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const path = require('path');
const temp = require('temp').track();
const os = require('os');
const {remote, shell} = require('electron');
const remoteShell = require('electron').remote.shell;
const Directory = require('../lib/directory');
const eventHelpers = require("./event-helpers");

Expand Down Expand Up @@ -4133,17 +4134,17 @@ describe("TreeView", function () {
});

describe("showSelectedEntryInFileManager()", function () {
beforeEach(() => spyOn(shell, 'showItemInFolder').andReturn(false));
beforeEach(() => spyOn(remoteShell, 'showItemInFolder').andReturn(false));

it("does nothing if no entry is selected", function () {
treeView.deselect();
treeView.showSelectedEntryInFileManager();
expect(shell.showItemInFolder).not.toHaveBeenCalled();
expect(remoteShell.showItemInFolder).not.toHaveBeenCalled();
});

it("shows the selected entry in the OS's file manager", function () {
treeView.showSelectedEntryInFileManager();
expect(shell.showItemInFolder).toHaveBeenCalled();
expect(remoteShell.showItemInFolder).toHaveBeenCalled();
});

it("displays a notification if showing the file fails", function () {
Expand All @@ -4155,13 +4156,13 @@ describe("TreeView", function () {
});

describe("showCurrentFileInFileManager()", function () {
beforeEach(() => spyOn(shell, 'showItemInFolder').andReturn(false));
beforeEach(() => spyOn(remoteShell, 'showItemInFolder').andReturn(false));

it("does nothing when no file is opened", function () {
expect(atom.workspace.getCenter().getPaneItems().length).toBe(0);

treeView.showCurrentFileInFileManager();
expect(shell.showItemInFolder).not.toHaveBeenCalled();
expect(remoteShell.showItemInFolder).not.toHaveBeenCalled();
});

it("does nothing when only an untitled tab is opened", function () {
Expand All @@ -4170,7 +4171,7 @@ describe("TreeView", function () {
return runs(function () {
workspaceElement.focus();
treeView.showCurrentFileInFileManager();
expect(shell.showItemInFolder).not.toHaveBeenCalled();
expect(remoteShell.showItemInFolder).not.toHaveBeenCalled();
});
});

Expand All @@ -4181,7 +4182,7 @@ describe("TreeView", function () {

return runs(function () {
treeView.showCurrentFileInFileManager();
expect(shell.showItemInFolder).toHaveBeenCalled();
expect(remoteShell.showItemInFolder).toHaveBeenCalled();
});
});

Expand Down

0 comments on commit 606b931

Please sign in to comment.