Summary: Changes where we delegate to the launcher to a later point so we can successfully intercept file open events and custom URI events. There's more information in Phase 1 in this paragraph of the doc: https://fb.quip.com/tpqnAbxnJw1w#UNZACAnVVGs Reviewed By: danielbuechele Differential Revision: D14563585 fbshipit-source-id: a8757a6072386e56102f15b0668456369a44aad7
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright 2018-present Facebook.
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
* @format
|
|
*/
|
|
|
|
const path = require('path');
|
|
const os = require('os');
|
|
const fs = require('fs');
|
|
const {spawn} = require('child_process');
|
|
|
|
module.exports = function(argv) {
|
|
if (!process.env.ANDROID_HOME) {
|
|
process.env.ANDROID_HOME = '/opt/android_sdk';
|
|
}
|
|
|
|
// emulator/emulator is more reliable than tools/emulator, so prefer it if
|
|
// it exists
|
|
process.env.PATH = `${process.env.ANDROID_HOME}/emulator:${
|
|
process.env.ANDROID_HOME
|
|
}/tools:${process.env.PATH}`;
|
|
|
|
// ensure .flipper folder and config exist
|
|
const flipperDir = path.join(os.homedir(), '.flipper');
|
|
if (!fs.existsSync(flipperDir)) {
|
|
fs.mkdirSync(flipperDir);
|
|
}
|
|
|
|
const configPath = path.join(flipperDir, 'config.json');
|
|
let config = {
|
|
pluginPaths: [],
|
|
disabledPlugins: [],
|
|
lastWindowPosition: {},
|
|
};
|
|
|
|
try {
|
|
config = {
|
|
...config,
|
|
...JSON.parse(fs.readFileSync(configPath)),
|
|
};
|
|
} catch (e) {
|
|
// file not readable or not parsable, overwrite it with the new config
|
|
fs.writeFileSync(configPath, JSON.stringify(config));
|
|
}
|
|
|
|
// Non-persistent CLI arguments.
|
|
config = {
|
|
...config,
|
|
updaterEnabled: argv.updater,
|
|
launcherMsg: argv.launcherMsg,
|
|
};
|
|
|
|
return {config, configPath, flipperDir};
|
|
};
|