open: add forceEngine
This commit is contained in:
parent
51f548e300
commit
c41d31a52f
16
src/index.js
16
src/index.js
@ -132,7 +132,7 @@ const getBrowserPath = async browser => {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const findBrowserPath = async (forceBrowser) => {
|
const findBrowserPath = async (forceBrowser, forceEngine) => {
|
||||||
if (forceBrowser) return [ await getBrowserPath(forceBrowser), forceBrowser ];
|
if (forceBrowser) return [ await getBrowserPath(forceBrowser), forceBrowser ];
|
||||||
|
|
||||||
for (const x in browserPaths) {
|
for (const x in browserPaths) {
|
||||||
@ -142,7 +142,11 @@ const findBrowserPath = async (forceBrowser) => {
|
|||||||
for (const x in browserPaths) {
|
for (const x in browserPaths) {
|
||||||
const path = await getBrowserPath(x);
|
const path = await getBrowserPath(x);
|
||||||
|
|
||||||
if (path) return [ path, x ];
|
if (path) {
|
||||||
|
if (forceEngine && getBrowserType(x) !== forceEngine) continue; // if forceEngine is set, ignore path if it isn't
|
||||||
|
|
||||||
|
return [ path, x ];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -160,8 +164,8 @@ const getBrowserType = name => { // todo: not need this
|
|||||||
return 'chromium';
|
return 'chromium';
|
||||||
};
|
};
|
||||||
|
|
||||||
const startBrowser = async (url, { windowSize, forceBrowser }) => {
|
const startBrowser = async (url, { windowSize, forceBrowser, forceEngine }) => {
|
||||||
const [ browserPath, browserName ] = await findBrowserPath(forceBrowser);
|
const [ browserPath, browserName ] = await findBrowserPath(forceBrowser, forceEngine);
|
||||||
const browserFriendlyName = getFriendlyName(browserName);
|
const browserFriendlyName = getFriendlyName(browserName);
|
||||||
|
|
||||||
if (!browserPath) return log('failed to find a good browser install');
|
if (!browserPath) return log('failed to find a good browser install');
|
||||||
@ -184,10 +188,10 @@ const startBrowser = async (url, { windowSize, forceBrowser }) => {
|
|||||||
return Window;
|
return Window;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const open = async (url, { windowSize, onLoad, forceBrowser } = {}) => {
|
export const open = async (url, { windowSize, onLoad, forceBrowser, forceEngine } = {}) => {
|
||||||
log('starting browser...');
|
log('starting browser...');
|
||||||
|
|
||||||
const Browser = await startBrowser(url, { windowSize, forceBrowser });
|
const Browser = await startBrowser(url, { windowSize, forceBrowser, forceEngine });
|
||||||
|
|
||||||
if (onLoad) {
|
if (onLoad) {
|
||||||
const toRun = `(() => {
|
const toRun = `(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user