Skip to content

Commit

Permalink
Add warning when running start without build (vercel#736)
Browse files Browse the repository at this point in the history
* add warning when running start without build

* run build before start

* Revert "run build before start"

This reverts commit 171b544.

* exit code & dir

* dont update yarn.lock

* use existsSync

* Add some style changes.
  • Loading branch information
ntwcklng authored and nkzawa committed Jan 11, 2017
1 parent 4fcc551 commit 23d5ea9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions 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 { existsSync } from 'fs'

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

const srv = new Server({ dir })

if (!existsSync(resolve(dir, '.next'))) {
console.error(`> Could not find the '.next' directory! Try building your app with 'next build' before starting the server.`)
process.exit(1)
}

srv.start(argv.port)
.then(() => {
if (!process.env.NOW) {
Expand All @@ -48,3 +55,4 @@ srv.start(argv.port)
console.error(err)
process.exit(1)
})

0 comments on commit 23d5ea9

Please sign in to comment.