start: support local files
This commit is contained in:
parent
cfca4cc1dd
commit
d95301199b
@ -3,7 +3,7 @@ global.log = (...args) => console.log(`[${rgb(88, 101, 242, 'Gluon')}]`, ...args
|
|||||||
|
|
||||||
process.versions.gluon = '0.11.0-alpha.7';
|
process.versions.gluon = '0.11.0-alpha.7';
|
||||||
|
|
||||||
import { join, dirname, delimiter, sep } from 'path';
|
import { join, dirname, delimiter, sep, resolve, isAbsolute } from 'path';
|
||||||
import { access, readdir } from 'fs/promises';
|
import { access, readdir } from 'fs/promises';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
@ -183,9 +183,10 @@ const startBrowser = async (url, { windowSize, forceBrowser, forceEngine }) => {
|
|||||||
|
|
||||||
const openingLocal = !url.includes('://');
|
const openingLocal = !url.includes('://');
|
||||||
const localUrl = browserType === 'firefox' ? `http://localhost:${generatePort()}` : 'https://gluon.local';
|
const localUrl = browserType === 'firefox' ? `http://localhost:${generatePort()}` : 'https://gluon.local';
|
||||||
|
const basePath = isAbsolute(url) ? url : join(ranJsDir, url);
|
||||||
|
|
||||||
const closeHandlers = [];
|
const closeHandlers = [];
|
||||||
if (openingLocal && browserType === 'firefox') closeHandlers.push(await LocalServer({ localUrl, url }));
|
if (openingLocal && browserType === 'firefox') closeHandlers.push(await LocalServer({ localUrl, url: basePath }));
|
||||||
|
|
||||||
const Window = await (browserType === 'firefox' ? Firefox : Chromium)({
|
const Window = await (browserType === 'firefox' ? Firefox : Chromium)({
|
||||||
dataPath,
|
dataPath,
|
||||||
@ -195,7 +196,7 @@ const startBrowser = async (url, { windowSize, forceBrowser, forceEngine }) => {
|
|||||||
windowSize
|
windowSize
|
||||||
}, {
|
}, {
|
||||||
browserName: browserFriendlyName,
|
browserName: browserFriendlyName,
|
||||||
url,
|
url: openingLocal ? basePath : url,
|
||||||
localUrl,
|
localUrl,
|
||||||
openingLocal,
|
openingLocal,
|
||||||
closeHandlers
|
closeHandlers
|
||||||
|
Loading…
x
Reference in New Issue
Block a user