Use 'open' module to open stuff
Summary: Instead of our ad-hoc mechanism. There's quite a bit of trickery involved to make this work reliably on Windows so I'd rather take an off-the-shelf solution than reimplement this myself. Reviewed By: jknoxville Differential Revision: D17628949 fbshipit-source-id: 98806b60a107231d9ee07b721ebb70f2cbd8aec1
This commit is contained in:
committed by
Facebook Github Bot
parent
ba559ac338
commit
0039d5be4a
@@ -125,6 +125,7 @@
|
|||||||
"lodash.debounce": "^4.0.8",
|
"lodash.debounce": "^4.0.8",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"node-fetch": "^2.3.0",
|
"node-fetch": "^2.3.0",
|
||||||
|
"open": "^6.4.0",
|
||||||
"openssl-wrapper": "^0.3.4",
|
"openssl-wrapper": "^0.3.4",
|
||||||
"p-map": "^3.0.0",
|
"p-map": "^3.0.0",
|
||||||
"pkg": "^4.3.7",
|
"pkg": "^4.3.7",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {reportPlatformFailures} from '../utils/metrics';
|
|||||||
import config from '../utils/processConfig';
|
import config from '../utils/processConfig';
|
||||||
import BaseDevice from '../devices/BaseDevice';
|
import BaseDevice from '../devices/BaseDevice';
|
||||||
import {State as Store} from '../reducers';
|
import {State as Store} from '../reducers';
|
||||||
|
import open from 'open';
|
||||||
|
|
||||||
const CAPTURE_LOCATION = expandTilde(
|
const CAPTURE_LOCATION = expandTilde(
|
||||||
config().screenCapturePath || remote.app.getPath('desktop'),
|
config().screenCapturePath || remote.app.getPath('desktop'),
|
||||||
@@ -36,27 +37,15 @@ type State = {
|
|||||||
capturingScreenshot: boolean;
|
capturingScreenshot: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
function openFile(path: string | null) {
|
async function openFile(path: string | null) {
|
||||||
if (!path) {
|
if (!path) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const child = spawn(getOpenCommand(), [path]);
|
|
||||||
child.on('exit', code => {
|
|
||||||
if (code != 0) {
|
|
||||||
console.error(`${getOpenCommand()} failed with exit code ${code}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getOpenCommand(): string {
|
try {
|
||||||
//TODO: TESTED ONLY ON MAC!
|
await open(path);
|
||||||
switch (os.platform()) {
|
} catch (e) {
|
||||||
case 'win32':
|
console.error(`Opening ${path} failed with error ${e}.`);
|
||||||
return 'start';
|
|
||||||
case 'linux':
|
|
||||||
return 'xdg-open';
|
|
||||||
default:
|
|
||||||
return 'open';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6665,6 +6665,13 @@ onetime@^2.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
mimic-fn "^1.0.0"
|
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:
|
openssl-wrapper@^0.3.4:
|
||||||
version "0.3.4"
|
version "0.3.4"
|
||||||
resolved "https://registry.yarnpkg.com/openssl-wrapper/-/openssl-wrapper-0.3.4.tgz#c01ec98e4dcd2b5dfe0b693f31827200e3b81b07"
|
resolved "https://registry.yarnpkg.com/openssl-wrapper/-/openssl-wrapper-0.3.4.tgz#c01ec98e4dcd2b5dfe0b693f31827200e3b81b07"
|
||||||
|
|||||||
Reference in New Issue
Block a user