Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #184 from sveltejs/gh-169-b
Browse files Browse the repository at this point in the history
Fix hard-coded port
  • Loading branch information
Rich-Harris authored Mar 10, 2018
2 parents e8f3aff + 7f98d50 commit 542115f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cli/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export default async function dev(port: number) {

deferreds.client.promise.then(() => {
function restart() {
ports.wait(3000).then(deferreds.server.fulfil); // TODO control port
ports.wait(port).then(deferreds.server.fulfil);
}

if (proc) {
Expand Down
8 changes: 6 additions & 2 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const prog = sade('sapper').version(pkg.version);
prog.command('dev')
.describe('Start a development server')
.option('-p, --port', 'Specify a port')
.action(async ({ port }: { port: number }) => {
.action(async (opts: { port: number }) => {
let port = opts.port || +process.env.PORT;

if (port) {
if (!await ports.check(port)) {
console.log(chalk.bold.red(`> Port ${port} is unavailable`));
Expand Down Expand Up @@ -53,7 +55,9 @@ prog.command('build [dest]')
prog.command('start [dir]')
.describe('Start your app')
.option('-p, --port', 'Specify a port')
.action(async (dir = 'build', { port }: { port: number }) => {
.action(async (dir = 'build', opts: { port: number }) => {
let port = opts.port || +process.env.PORT;

const resolved = path.resolve(dir);
const server = path.resolve(dir, 'server.js');

Expand Down

0 comments on commit 542115f

Please sign in to comment.