File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22
3- import { resolve } from 'path'
3+ import { resolve , join } from 'path'
4+ import { exists } from 'mz/fs'
45import parseArgs from 'minimist'
56import build from '../server/build'
67
@@ -27,6 +28,23 @@ if (argv.help) {
2728
2829const dir = resolve ( argv . _ [ 0 ] || '.' )
2930
31+ // Check if pages dir exists and warn if not
32+ exists ( dir )
33+ . then ( async ( ) => {
34+ if ( ! ( await exists ( join ( dir , 'pages' ) ) ) ) {
35+ if ( await exists ( join ( dir , '..' , 'pages' ) ) ) {
36+ console . error ( '> No `pages` directory found. Did you mean to run `next` in the parent (`../`) directory?' )
37+ } else {
38+ console . error ( '> Couldn\'t find a `pages` directory. Please create one under the project root' )
39+ }
40+ process . exit ( 1 )
41+ }
42+ } )
43+ . catch ( ( err ) => {
44+ console . error ( err )
45+ process . exit ( 1 )
46+ } )
47+
3048build ( dir )
3149. catch ( ( err ) => {
3250 console . error ( err )
Original file line number Diff line number Diff line change @@ -37,14 +37,9 @@ if (argv.help) {
3737
3838const dir = resolve ( argv . _ [ 0 ] || '.' )
3939
40- const srv = new Server ( { dir, dev : true } )
41- srv . start ( argv . port )
40+ // Check if pages dir exists and warn if not
41+ exists ( dir )
4242. then ( async ( ) => {
43- if ( ! process . env . NOW ) {
44- console . log ( `> Ready on http://localhost:${ argv . port } ` )
45- }
46-
47- // Check if pages dir exists and warn if not
4843 if ( ! ( await exists ( join ( dir , 'pages' ) ) ) ) {
4944 if ( await exists ( join ( dir , '..' , 'pages' ) ) ) {
5045 console . error ( '> No `pages` directory found. Did you mean to run `next` in the parent (`../`) directory?' )
@@ -58,3 +53,15 @@ srv.start(argv.port)
5853 console . error ( err )
5954 process . exit ( 1 )
6055} )
56+
57+ const srv = new Server ( { dir, dev : true } )
58+ srv . start ( argv . port )
59+ . then ( async ( ) => {
60+ if ( ! process . env . NOW ) {
61+ console . log ( `> Ready on http://localhost:${ argv . port } ` )
62+ }
63+ } )
64+ . catch ( ( err ) => {
65+ console . error ( err )
66+ process . exit ( 1 )
67+ } )
You can’t perform that action at this time.
0 commit comments