diff --git a/package.json b/package.json index cfbe917c4..4dd567af7 100644 --- a/package.json +++ b/package.json @@ -125,6 +125,7 @@ "lodash.debounce": "^4.0.8", "mkdirp": "^0.5.1", "node-fetch": "^2.3.0", + "open": "^6.4.0", "openssl-wrapper": "^0.3.4", "p-map": "^3.0.0", "pkg": "^4.3.7", diff --git a/src/chrome/ScreenCaptureButtons.tsx b/src/chrome/ScreenCaptureButtons.tsx index bcc632b99..731554c89 100644 --- a/src/chrome/ScreenCaptureButtons.tsx +++ b/src/chrome/ScreenCaptureButtons.tsx @@ -17,6 +17,7 @@ import {reportPlatformFailures} from '../utils/metrics'; import config from '../utils/processConfig'; import BaseDevice from '../devices/BaseDevice'; import {State as Store} from '../reducers'; +import open from 'open'; const CAPTURE_LOCATION = expandTilde( config().screenCapturePath || remote.app.getPath('desktop'), @@ -36,27 +37,15 @@ type State = { capturingScreenshot: boolean; }; -function openFile(path: string | null) { +async function openFile(path: string | null) { if (!path) { return; } - const child = spawn(getOpenCommand(), [path]); - child.on('exit', code => { - if (code != 0) { - console.error(`${getOpenCommand()} failed with exit code ${code}`); - } - }); -} -function getOpenCommand(): string { - //TODO: TESTED ONLY ON MAC! - switch (os.platform()) { - case 'win32': - return 'start'; - case 'linux': - return 'xdg-open'; - default: - return 'open'; + try { + await open(path); + } catch (e) { + console.error(`Opening ${path} failed with error ${e}.`); } } diff --git a/yarn.lock b/yarn.lock index 12a15506a..21ae3744c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6665,6 +6665,13 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" +open@^6.4.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/open/-/open-6.4.0.tgz#5c13e96d0dc894686164f18965ecfe889ecfc8a9" + integrity sha512-IFenVPgF70fSm1keSd2iDBIDIBZkroLeuffXq+wKTzTJlBpesFWojV9lb8mzOfaAzM1sr7HQHuO0vtV0zYekGg== + dependencies: + is-wsl "^1.1.0" + openssl-wrapper@^0.3.4: version "0.3.4" resolved "https://registry.yarnpkg.com/openssl-wrapper/-/openssl-wrapper-0.3.4.tgz#c01ec98e4dcd2b5dfe0b693f31827200e3b81b07"