mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-16 05:38:41 -09:00
windows: fix editing preferences on bash (#1571)
* windows: fix editing preferences on bash * linter: fix the linting error * cleanCode : move the code to a function * cleanCode: move the constants to the function * clean: remove unnecessary eslint comment * clean: use platform instead of defining it
This commit is contained in:
parent
d521e8e162
commit
36f96abb1d
1 changed files with 23 additions and 9 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import {EOL} from 'os';
|
import {EOL} from 'os';
|
||||||
|
|
||||||
|
import {remote} from 'electron';
|
||||||
import * as shellEscape from 'php-escape-shell';
|
import * as shellEscape from 'php-escape-shell';
|
||||||
import last from '../utils/array';
|
import last from '../utils/array';
|
||||||
import isExecutable from '../utils/file';
|
import isExecutable from '../utils/file';
|
||||||
|
|
@ -209,15 +210,29 @@ export function moveTo(i) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getEditCommand(shell, isWin) {
|
||||||
|
if (isWin && shell.includes('bash')) {
|
||||||
|
return [
|
||||||
|
' nano .hyper.js',
|
||||||
|
'echo Attempting to open .hyper.js with nano'
|
||||||
|
];
|
||||||
|
} else if (isWin) {
|
||||||
|
return [
|
||||||
|
' start notepad "%userprofile%\\.hyper.js"',
|
||||||
|
'echo Attempting to open .hyper.js with notepad'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
// eslint-disable-next-line no-template-curly-in-string
|
||||||
|
' bash -c \'exec env ${EDITOR:=nano} ~/.hyper.js\'',
|
||||||
|
'echo Attempting to open ~/.hyper.js with your \\$EDITOR'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
export function showPreferences() {
|
export function showPreferences() {
|
||||||
const isWin = process.platform === 'win32';
|
const plugins = remote.require('./plugins');
|
||||||
// eslint-disable-next-line no-template-curly-in-string
|
const {shell} = plugins.getDecoratedConfig();
|
||||||
const command = isWin ? ' start notepad "%userprofile%\\.hyper.js"' : ' bash -c \'exec env ${EDITOR:=nano} ~/.hyper.js\'';
|
const message = getEditCommand(shell, process.platform === 'win32');
|
||||||
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 => {
|
return dispatch => {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|
@ -231,7 +246,6 @@ export function showPreferences() {
|
||||||
uid,
|
uid,
|
||||||
[
|
[
|
||||||
...message,
|
...message,
|
||||||
command,
|
|
||||||
''
|
''
|
||||||
].join(EOL)
|
].join(EOL)
|
||||||
));
|
));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue