Summary: This seems like a better approach than ad-hoc lookup in `electron.remove.argv`. Left a note to a task to provide a better interface to this. I also need this in order to ensure we're starting Flipper through the launcher which needs to happen before we start the Electron runtime. Reviewed By: jknoxville Differential Revision: D13881355 fbshipit-source-id: 69c70d71035a47084f789ddb4dc969b45ba4648b
54 lines
1.3 KiB
JavaScript
54 lines
1.3 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');
|
|
|
|
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,
|
|
};
|
|
|
|
return {config, configPath, flipperDir};
|
|
};
|