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

Commit

Permalink
Added auto launching of browser on start
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylankjy committed Sep 12, 2021
1 parent b394b96 commit 85aa6aa
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ app.use('/third_party', express.static('third_party'))
// BodyParser
app.use(express.urlencoded({ extended: true }))


// CookieParser
const cookieParser = require('cookie-parser')
app.use(cookieParser())

Expand All @@ -25,6 +25,8 @@ app.engine('hbs', exphbs({
// Routes
require('./app/routes/routes')(app)

// Open in browser
const open = require('open')
const webserverPort = 3000

const webserver = () => {
Expand All @@ -33,7 +35,13 @@ const webserver = () => {
console.log(`\x1b[1m\x1b[2m[WEBSERVER] - \x1b[0m\x1b[1m\x1b[31m\x1b[5mFAILED\x1b[0m\x1b[31m: Unable to bind to port 5000. Could there possibly be another instance alive?\x1b[0m`)
process.exit(1)
}
console.log(`\x1b[1m\x1b[2m[WEBSERVER] - \x1b[1m\x1b[34mOK\x1b[0m: Webserver binded on port ${webserverPort} | http://localhost:${webserverPort}\x1b[0m`)
// console.log(`\x1b[1m\x1b[2m[WEBSERVER] - \x1b[1m\x1b[34mOK\x1b[0m: Webserver binded on port ${webserverPort} | http://localhost:${webserverPort}\x1b[0m`)
console.log(`${chalk.greenBright('Loaded and ready: ')}${chalk.whiteBright('Launching Metronami in your browser...')}`)
open(`http://localhost:${webserverPort}`)

setTimeout(() => {
console.log(`${chalk.cyan('Nothing happened? ')}${chalk.whiteBright('You may manually access Metronami at http://localhost:' + webserverPort)}`)
}, 5000)
})
}

Expand Down

0 comments on commit 85aa6aa

Please sign in to comment.