Skip to content

Commit

Permalink
scan port
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Nov 4, 2019
1 parent 2e899fe commit 41a52f2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
12 changes: 6 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const defaultSettings = {
cors: true,
dirs: true,
index: true,
scan: true,
recent: [],
};
const maxRecent = 10;
Expand Down Expand Up @@ -180,12 +181,12 @@ function startServer() {
error: errorToWindow,
},
}));
servez.on('start', () => {
servez.on('start', (startInfo) => {
running = true;
if (!isShell) {
saveSettings();
}
sendToWindow('started');
sendToWindow('started', startInfo);
sendToWindow('settings', settings);
});
servez.on('close', serverClosed);
Expand Down Expand Up @@ -241,9 +242,8 @@ function getSettings(event) {
event.sender.send((running && servez) ? 'started' : 'stopped');
}

function launch(event) {
const url = "http://localhost:" + settings.port;
electron.shell.openExternal(url);
function launch(event, startInfo) {
electron.shell.openExternal(startInfo.baseUrl);
}

function logToWindow(...args) {
Expand Down Expand Up @@ -293,7 +293,7 @@ if (isShell) {
app.on('window-all-closed', () => {
mainWebContents = null;
if (running && servez) {
servez.destroy();
servez.close();
}
app.quit();
});
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"optionator": "^0.8.2",
"serve-index": "^1.9.1",
"server-destroy": "^1.0.1",
"servez-lib": "^1.1.2"
"servez-lib": "^1.2.0"
},
"devDependencies": {
"cross-env": "^6.0.3",
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const clearElem = $("#clear");

launchElem.disabled = true;

let startInfo;
const settingsInfo = {
};

Expand Down Expand Up @@ -89,7 +90,8 @@ ipcRenderer.on('error', (event, ...args) => {
error(...args);
});

ipcRenderer.on('started', () => {
ipcRenderer.on('started', (event, newStartInfo) => {
startInfo = newStartInfo;
startElem.textContent = "Stop";
launchElem.disabled = false;
});
Expand Down Expand Up @@ -180,7 +182,7 @@ startElem.addEventListener('click', e => {
});

launchElem.addEventListener('click', e => {
ipcRenderer.send('launch');
ipcRenderer.send('launch', startInfo);
});

async function getFolderToServe() {
Expand Down

0 comments on commit 41a52f2

Please sign in to comment.