Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bin/next-start
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { resolve } from 'path'
import parseArgs from 'minimist'
import Server from '../server'
import {exists} from 'mz/fs'

const argv = parseArgs(process.argv.slice(2), {
alias: {
Expand Down Expand Up @@ -38,7 +39,14 @@ if (argv.help) {
const dir = resolve(argv._[0] || '.')

const srv = new Server({ dir })
srv.start(argv.port)

exists(resolve(process.cwd(), '.next')).then(exists => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be dir not process.cwd()

if (!exists) {
console.error(`> Error! The application should be compiled with \`next build\` first.`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about a message like this:

Could not found the '.next' directory! Try building your app with 'next build' before starting the server.

cc @rauchg

process.exit(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need exit with a non-zero code.

}
srv.start(argv.port)
})
.then(() => {
if (!process.env.NOW) {
console.log(`> Ready on http://localhost:${argv.port}`)
Expand All @@ -48,3 +56,4 @@ srv.start(argv.port)
console.error(err)
process.exit(1)
})

Loading