Skip to content

Commit

Permalink
Merge 87b39c5 into 9996df4
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyanziano committed May 2, 2019
2 parents 9996df4 + 87b39c5 commit 366f196
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
Expand Up @@ -32,6 +32,8 @@
//

// Cheating here and pulling in a module from node. Can be easily replaced if we ever move the emulator to the web.
import { join, normalize } from 'path';

import {
ExtensionInspector,
InspectorAccessory,
Expand Down Expand Up @@ -71,8 +73,8 @@ interface IpcMessageEvent extends Event {
}

interface InspectorProps {
appPath?: string;
document: any;
cwdAsBase: string;
themeInfo: { themeName: string; themeComponents: string[] };
activeBot?: IBotConfiguration;
botHash?: string;
Expand Down Expand Up @@ -297,13 +299,8 @@ export class Inspector extends React.Component<InspectorProps, InspectorState> {
}

private createWebView(state: InspectorState): ElectronHTMLWebViewElement {
// const { cwdAsBase } = this.props;
// const preload = `file://${cwdAsBase}/../../../node_modules/@bfemulator/client/public/inspector-preload.js`;
// const preload = `file://node_modules/@bfemulator/client/public/inspector-preload.js`;
// THIS IS A HACK!! WILL FIX LATER
const preload = state.inspector.src
.replace(/extension-.*/, 'client/public/inspector-preload.js')
.replace('asar.unpacked', 'asar');
const appPath = normalize(this.props.appPath);
const preload = normalize(join('file://', appPath, '/node_modules/@bfemulator/client/public/inspector-preload.js'));
const webView: ElectronHTMLWebViewElement = document.createElement('webview');

webView.className = styles.webViewContainer;
Expand Down
Expand Up @@ -41,15 +41,12 @@ import { Inspector } from './inspector';

const mapStateToProps = (state: RootState, ownProps: any) => {
const { bot, theme, clientAwareSettings } = state;
const cwdAsBase = !(clientAwareSettings.cwd || '').startsWith('/')
? `/${clientAwareSettings.cwd}`
: clientAwareSettings.cwd;
return {
...ownProps,
appPath: clientAwareSettings.appPath,
botHash: bot.activeBotDigest,
activeBot: bot.activeBot,
themeInfo: theme,
cwdAsBase,
};
};

Expand Down
4 changes: 4 additions & 0 deletions packages/app/main/src/commands/emulatorCommands.spec.ts
Expand Up @@ -63,6 +63,10 @@ let mockStore;
return mockStore || (mockStore = createStore(combineReducers({ bot })));
};

jest.mock('electron', () => ({
app: { getAppPath: () => '' },
}));

const mockOn = { on: () => mockOn };
jest.mock('chokidar', () => ({
watch: () => ({
Expand Down
Expand Up @@ -77,6 +77,10 @@ jest.mock('../../main', () => ({
}));
const sagaMiddleWare = sagaMiddlewareFactory();

jest.mock('electron', () => ({
app: { getAppPath: () => '' },
}));

describe('The SettingsSagas', () => {
beforeEach(() => {
mockStore = createStore(
Expand All @@ -96,7 +100,7 @@ describe('The SettingsSagas', () => {
expect(commandServiceSpy).toHaveBeenCalledWith(SharedConstants.Commands.UI.SwitchTheme, 'myTheme', 'myTheme.scss');
});

it('should orchesrtate the changes needed when switching debug modes', async () => {
it('should orchestrate the changes needed when switching debug modes', async () => {
const localCommandServiceSpy = jest.spyOn(mainWindow.commandService, 'call').mockResolvedValue(true);
const remoteCommandServiceSpy = jest.spyOn(mainWindow.commandService, 'remoteCall');

Expand Down
2 changes: 2 additions & 0 deletions packages/app/main/src/settingsData/sagas/settingsSagas.ts
Expand Up @@ -34,6 +34,7 @@ import { DebugMode, FrameworkSettings, Settings, SharedConstants } from '@bfemul
import { Users } from '@bfemulator/emulator-core';
import { ClientAwareSettings } from '@bfemulator/app-shared';
import { call, ForkEffect, select, takeEvery } from 'redux-saga/effects';
import { app } from 'electron';

import { Emulator } from '../../emulator';
import { mainWindow } from '../../main';
Expand Down Expand Up @@ -138,6 +139,7 @@ function* pushClientAwareSettings() {
[mainWindow.commandService, mainWindow.commandService.remoteCall],
SharedConstants.Commands.Settings.ReceiveGlobalSettings,
{
appPath: app.getAppPath(),
serverUrl: (Emulator.getInstance().framework.serverUrl || '').replace('[::]', 'localhost'),
cwd: (process.cwd() || '').replace(/\\/g, '/'),
users: settingsState.users,
Expand Down
1 change: 1 addition & 0 deletions packages/app/shared/src/types/clientAwareSettings.ts
Expand Up @@ -33,6 +33,7 @@
import { DebugMode, UserSettings } from './serverSettingsTypes';

export interface ClientAwareSettings {
appPath: string;
cwd: string;
locale: string;
serverUrl: string;
Expand Down

0 comments on commit 366f196

Please sign in to comment.