Delegate to launcher app on startup
Summary: For the production version, if the Launcher is installed and no `--no-launcher` (note the double-negation) is supplied, then let the launcher start the app instead. The launcher will pass the `--no-launcher` option back to prevent this from looping. Reviewed By: jknoxville Differential Revision: D14066620 fbshipit-source-id: 27d305efac36005e5e1082076829f10ef14aba0d
This commit is contained in:
committed by
Facebook Github Bot
parent
2b9e3c54c6
commit
a41d8eb4f8
@@ -8,8 +8,37 @@
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
const {spawn} = require('child_process');
|
||||
|
||||
const isProduction = () =>
|
||||
!/node_modules[\\/]electron[\\/]/.test(process.execPath);
|
||||
|
||||
const isLauncherInstalled = () => {
|
||||
if (os.type() == 'Darwin') {
|
||||
const receipt = 'com.facebook.flipper.launcher';
|
||||
const plistLocation = '/Applications/Flipper.app/Contents/Info.plist';
|
||||
return (
|
||||
fs.existsSync(plistLocation) &&
|
||||
fs.readFileSync(plistLocation).indexOf(receipt) > 0
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
const startLauncher = () => {
|
||||
if (os.type() == 'Darwin') {
|
||||
spawn('open', ['/Applications/Flipper.app']);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function(argv) {
|
||||
if (argv.launcher && isProduction() && isLauncherInstalled()) {
|
||||
console.warn('Delegating to Flipper Launcher ...');
|
||||
startLauncher();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (!process.env.ANDROID_HOME) {
|
||||
process.env.ANDROID_HOME = '/opt/android_sdk';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user