From d4c1d08701bf161484c4c97ba7817b08894106c2 Mon Sep 17 00:00:00 2001 From: Matheus Fernandes Date: Wed, 15 Feb 2017 12:12:48 -0300 Subject: [PATCH] Revert "Open Preferences in Default JS Editor on Windows" (#1510) --- lib/actions/ui.js | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/actions/ui.js b/lib/actions/ui.js index f427c7f1..f9b46c28 100644 --- a/lib/actions/ui.js +++ b/lib/actions/ui.js @@ -1,6 +1,4 @@ -import os from 'os'; -import {shell} from 'electron'; -import path from 'path'; +import {EOL} from 'os'; import * as shellEscape from 'php-escape-shell'; import last from '../utils/array'; @@ -212,12 +210,33 @@ export function moveTo(i) { } export function showPreferences() { + const isWin = process.platform === 'win32'; + // eslint-disable-next-line no-template-curly-in-string + const command = isWin ? ' start notepad "%userprofile%\\.hyper.js"' : ' bash -c \'exec env ${EDITOR:=nano} ~/.hyper.js\''; + const message = []; + message.push(isWin ? + ' echo Attempting to open ^%userprofile^%\\.hyper.js with notepad' : + ' echo Attempting to open ~/.hyper.js with your \\$EDITOR'); + message.push(' echo If it fails, open it manually with your favorite editor!'); + return dispatch => { dispatch({ type: UI_SHOW_PREFERENCES, effect() { - dispatch( - shell.showItemInFolder(path.join(os.homedir(), '.hyper.js'))); + dispatch(requestSession()); + // Replace this hack with an async action + rpc.once('session add', ({uid}) => { + rpc.once('session data', () => { + dispatch(sendSessionData( + uid, + [ + ...message, + command, + '' + ].join(EOL) + )); + }); + }); } }); };