Switch to using settings for android sdk location
Summary: A settings screen has been added where android home can be set. This changes the downstream code to use this value rather than the `env.PATH` variable. Reviewed By: passy Differential Revision: D17713288 fbshipit-source-id: 51551652c9c2f468e1117c18785123348e4b4576
This commit is contained in:
committed by
Facebook Github Bot
parent
85c0ec0d13
commit
729e74f2fc
20
src/init.tsx
20
src/init.tsx
@@ -16,7 +16,7 @@ import BugReporter from './fb-stubs/BugReporter';
|
||||
import setupPrefetcher from './fb-stubs/Prefetcher';
|
||||
import {createStore} from 'redux';
|
||||
import {persistStore} from 'redux-persist';
|
||||
import reducers, {Actions, State as StoreState} from './reducers/index';
|
||||
import reducers, {Store, Actions, State as StoreState} from './reducers/index';
|
||||
import dispatcher from './dispatcher/index';
|
||||
import TooltipProvider from './ui/components/TooltipProvider';
|
||||
import config from './utils/processConfig';
|
||||
@@ -27,6 +27,7 @@ import fbConfig from './fb-stubs/config';
|
||||
import {isFBEmployee} from './utils/fbEmployee';
|
||||
import WarningEmployee from './chrome/WarningEmployee';
|
||||
import React from 'react';
|
||||
import path from 'path';
|
||||
|
||||
const store = createStore<StoreState, Actions, any, any>(
|
||||
reducers,
|
||||
@@ -72,6 +73,21 @@ const AppFrame = () => {
|
||||
);
|
||||
};
|
||||
|
||||
function setProcessState(store: Store) {
|
||||
const androidHome = store.getState().settingsState.androidHome;
|
||||
|
||||
if (!process.env.ANDROID_HOME) {
|
||||
process.env.ANDROID_HOME = androidHome;
|
||||
}
|
||||
|
||||
// emulator/emulator is more reliable than tools/emulator, so prefer it if
|
||||
// it exists
|
||||
process.env.PATH =
|
||||
['emulator', 'tools', 'platform-tools']
|
||||
.map(directory => path.resolve(androidHome, directory))
|
||||
.join(':') + `:${process.env.PATH}`;
|
||||
}
|
||||
|
||||
function init() {
|
||||
ReactDOM.render(<AppFrame />, document.getElementById('root'));
|
||||
initLauncherHooks(config(), store);
|
||||
@@ -85,6 +101,8 @@ function init() {
|
||||
|
||||
// rehydrate app state before exposing init
|
||||
persistStore(store, undefined, () => {
|
||||
// Make sure process state is set before dispatchers run
|
||||
setProcessState(store);
|
||||
dispatcher(store, logger);
|
||||
// make init function callable from outside
|
||||
window.Flipper.init = init;
|
||||
|
||||
Reference in New Issue
Block a user