Skip to content

Commit 00693de

Browse files
chabourauchg
authored andcommitted
Open Hyper config in the native desktop's default manner (#1784)
1 parent c491f7d commit 00693de

File tree

3 files changed

+7
-66
lines changed

3 files changed

+7
-66
lines changed

app/menu.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const path = require('path');
33
const {app, shell, dialog} = require('electron');
44

55
const {accelerators} = require('./accelerators');
6+
const {getConfigDir} = require('./config');
67

78
const isMac = process.platform === 'darwin';
89
const appName = app.getName();
@@ -25,12 +26,9 @@ module.exports = ({createWindow, updatePlugins}) => {
2526
{
2627
label: 'Preferences...',
2728
accelerator: accelerators.preferences,
28-
click(item, focusedWindow) {
29-
if (focusedWindow) {
30-
focusedWindow.rpc.emit('preferences');
31-
} else {
32-
createWindow(win => win.rpc.emit('preferences'));
33-
}
29+
click() {
30+
const configFile = path.resolve(getConfigDir(), '.hyper.js');
31+
shell.openItem(configFile);
3432
}
3533
},
3634
{
@@ -174,12 +172,9 @@ module.exports = ({createWindow, updatePlugins}) => {
174172
{
175173
label: 'Preferences...',
176174
accelerator: accelerators.preferences,
177-
click(item, focusedWindow) {
178-
if (focusedWindow) {
179-
focusedWindow.rpc.emit('preferences');
180-
} else {
181-
createWindow(win => win.rpc.emit('preferences'));
182-
}
175+
click() {
176+
const configFile = path.resolve(getConfigDir(), '.hyper.js');
177+
shell.openItem(configFile);
183178
}
184179
}
185180
);

lib/actions/ui.js

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import {EOL} from 'os';
2-
3-
import {remote} from 'electron';
41
import * as shellEscape from 'php-escape-shell';
52
import last from '../utils/array';
63
import isExecutable from '../utils/file';
@@ -24,7 +21,6 @@ import {
2421
UI_MOVE_TO,
2522
UI_MOVE_NEXT_PANE,
2623
UI_MOVE_PREV_PANE,
27-
UI_SHOW_PREFERENCES,
2824
UI_WINDOW_GEOMETRY_CHANGED,
2925
UI_WINDOW_MOVE,
3026
UI_OPEN_FILE
@@ -210,52 +206,6 @@ export function moveTo(i) {
210206
};
211207
}
212208

213-
function getEditCommand(shell, isWin) {
214-
if (isWin && shell.includes('bash')) {
215-
return [
216-
' echo Attempting to open .hyper.js with nano',
217-
' nano .hyper.js'
218-
];
219-
} else if (isWin) {
220-
return [
221-
' echo Attempting to open .hyper.js with notepad',
222-
' start notepad "%userprofile%\\.hyper.js"'
223-
];
224-
}
225-
return [
226-
' echo Attempting to open ~/.hyper.js with your \\$EDITOR',
227-
// eslint-disable-next-line no-template-curly-in-string
228-
' bash -c \'exec env ${EDITOR:=nano} ~/.hyper.js\''
229-
];
230-
}
231-
232-
export function showPreferences() {
233-
const plugins = remote.require('./plugins');
234-
const {shell} = plugins.getDecoratedConfig();
235-
const message = getEditCommand(shell, process.platform === 'win32');
236-
237-
return dispatch => {
238-
dispatch({
239-
type: UI_SHOW_PREFERENCES,
240-
effect() {
241-
dispatch(requestSession());
242-
// Replace this hack with an async action
243-
rpc.once('session add', ({uid}) => {
244-
rpc.once('session data', () => {
245-
dispatch(sendSessionData(
246-
uid,
247-
[
248-
...message,
249-
''
250-
].join(EOL)
251-
));
252-
});
253-
});
254-
}
255-
});
256-
};
257-
}
258-
259209
export function windowMove() {
260210
return dispatch => {
261211
dispatch({

lib/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ rpc.on('prev pane req', () => {
126126
store_.dispatch(uiActions.moveToPreviousPane());
127127
});
128128

129-
rpc.on('preferences', () => {
130-
store_.dispatch(uiActions.showPreferences());
131-
});
132-
133129
rpc.on('open file', ({path}) => {
134130
store_.dispatch(uiActions.openFile(path));
135131
});

0 commit comments

Comments
 (0)