Skip to content

Commit

Permalink
fix(#90): await open args
Browse files Browse the repository at this point in the history
  • Loading branch information
jannis-baum committed Jul 15, 2024
1 parent 0a037a6 commit b72355a
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,24 @@ export const { clientsAt, messageClientsAt } = setupSockets(
);

const address = `http://localhost:${config.port}`;
const openArgs = () => {
for (const path of process.argv.slice(2)) {
if (path.startsWith('-')) continue;
if (!existsSync(path)) {
console.log(`File not found: ${path}`);
continue;
}
const absolute = presolve(path);
const url = `${address}${pathToURL(absolute)}`;
open(url);
}
const openArgs = async () => {
await Promise.all(
process.argv.slice(2).map(async (path) => {
if (path.startsWith('-')) return;
if (!existsSync(path)) {
console.log(`File not found: ${path}`);
return;
}
const absolute = presolve(path);
const url = `${address}${pathToURL(absolute)}`;
await open(url);
}),
);
};

get(`${address}/health`, () => {
get(`${address}/health`, async () => {
// server is already running
openArgs();
await openArgs();
process.exit(0);
}).on('error', () => {
// server is not running so we start it
Expand Down

0 comments on commit b72355a

Please sign in to comment.