Skip to content

Commit

Permalink
Show port number even if not defined as option
Browse files Browse the repository at this point in the history
  • Loading branch information
leo committed Jan 15, 2017
1 parent 770f535 commit 6469086
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions bin/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const updateNotifier = require('update-notifier')
// Ours
const pkg = require('../package')

// Support for keywords "async" and "await"
asyncToGen({
excludes: null
})
Expand All @@ -17,4 +18,5 @@ if (!process.env.NOW) {
updateNotifier({pkg}).notify()
}

// Load package core with async/await support
require('../lib')
4 changes: 2 additions & 2 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const fs = require('fs-promise')
// Ours
const prepareView = require('./view')

module.exports = async (flags, current, dir, ignoredFiles) => {
module.exports = async (port, current, dir, ignoredFiles) => {
let files = []
const subPath = path.relative(current, dir)

Expand Down Expand Up @@ -93,7 +93,7 @@ module.exports = async (flags, current, dir, ignoredFiles) => {
}

const details = {
port: flags.port,
port,
files,
assetDir: process.env.ASSET_DIR,
directory,
Expand Down
3 changes: 2 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ module.exports = async (req, res, flags, current, ignoredFiles) => {

if (!fs.existsSync(indexPath)) {
// Try to render the current directory's content
const renderedDir = await renderDirectory(flags, current, related, ignoredFiles)
const port = flags.port || req.socket.localPort
const renderedDir = await renderDirectory(port, current, related, ignoredFiles)

// If it works, send the directory listing to the user
if (renderedDir) {
Expand Down

0 comments on commit 6469086

Please sign in to comment.