Skip to content

Commit

Permalink
Add warning if wrapper port was already open. Close aragon#75
Browse files Browse the repository at this point in the history
  • Loading branch information
izqui authored and 0xGabi committed Jan 5, 2019
1 parent 1db03ef commit f0a4de2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/aragon-cli/src/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const { Writable } = require('stream')
const url = require('url')

const TX_MIN_GAS = 10e6
const WRAPPER_PORT = 3000

exports.command = 'run'

Expand Down Expand Up @@ -297,6 +298,10 @@ exports.handler = function ({
{
title: 'Start Aragon client',
task: async (ctx, task) => {
if (await isPortTaken(WRAPPER_PORT)) {
ctx.portOpen = true
return
}
const bin = await getNodePackageManager()
execa(
bin,
Expand Down Expand Up @@ -326,9 +331,9 @@ exports.handler = function ({
// Check until the wrapper is served
const checkWrapperReady = () => {
setTimeout(async () => {
const portTaken = await isPortTaken(3000)
const portTaken = await isPortTaken(WRAPPER_PORT)
if (portTaken) {
opn(`http://localhost:3000/#/${ctx.daoAddress}`)
opn(`http://localhost:${WRAPPER_PORT}/#/${ctx.daoAddress}`)
} else {
checkWrapperReady()
}
Expand All @@ -349,6 +354,9 @@ exports.handler = function ({
}

return tasks.run().then(async (ctx) => {
if (ctx.portOpen) {
reporter.warning(`Server already listening at port ${WRAPPER_PORT}, skipped starting Aragon`)
}

reporter.info(`You are now ready to open your app in Aragon.`)

Expand Down

0 comments on commit f0a4de2

Please sign in to comment.