From 795da23418777f184e23fdf06983e0efbedb4b32 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Fri, 15 Feb 2019 18:50:34 -0800 Subject: [PATCH] fix: fix "sapper export" with a custom PORT Fixes #565 --- src/api/export.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/export.ts b/src/api/export.ts index ed601e4..b539aac 100644 --- a/src/api/export.ts +++ b/src/api/export.ts @@ -60,7 +60,8 @@ async function _export({ sander.copyFileSync(build_dir, 'service-worker.js.map').to(export_dir, 'service-worker.js.map'); } - const port = await ports.find(3000); + const defaultPort = process.env.PORT ? parseInt(process.env.PORT) : 3000; + const port = await ports.find(defaultPort); const protocol = 'http:'; const host = `localhost:${port}`; @@ -199,4 +200,4 @@ async function _export({ function get_href(attrs: string) { const match = /href\s*=\s*(?:"(.*?)"|'(.+?)'|([^\s>]+))/.exec(attrs); return match[1] || match[2] || match[3]; -} \ No newline at end of file +}