Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Improve "pages/ not found error" #624

Merged
merged 2 commits into from
Jan 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 19 additions & 1 deletion bin/next-build
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node

import { resolve } from 'path'
import { resolve, join } from 'path'
import { exists } from 'mz/fs'
import parseArgs from 'minimist'
import build from '../server/build'

Expand All @@ -27,6 +28,23 @@ if (argv.help) {

const dir = resolve(argv._[0] || '.')

// Check if pages dir exists and warn if not
exists(dir)
.then(async () => {
if (!(await exists(join(dir, 'pages')))) {
if (await exists(join(dir, '..', 'pages'))) {
console.error('> No `pages` directory found. Did you mean to run `next` in the parent (`../`) directory?')
} else {
console.error('> Couldn\'t find a `pages` directory. Please create one under the project root')
}
process.exit(1)
}
})
.catch((err) => {
console.error(err)
process.exit(1)
})

build(dir)
.catch((err) => {
console.error(err)
Expand Down
21 changes: 14 additions & 7 deletions bin/next-dev
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,9 @@ if (argv.help) {

const dir = resolve(argv._[0] || '.')

const srv = new Server({ dir, dev: true })
srv.start(argv.port)
// Check if pages dir exists and warn if not
exists(dir)
.then(async () => {
if (!process.env.NOW) {
console.log(`> Ready on http://localhost:${argv.port}`)
}

// Check if pages dir exists and warn if not
if (!(await exists(join(dir, 'pages')))) {
if (await exists(join(dir, '..', 'pages'))) {
console.error('> No `pages` directory found. Did you mean to run `next` in the parent (`../`) directory?')
Expand All @@ -58,3 +53,15 @@ srv.start(argv.port)
console.error(err)
process.exit(1)
})

const srv = new Server({ dir, dev: true })
srv.start(argv.port)
.then(async () => {
if (!process.env.NOW) {
console.log(`> Ready on http://localhost:${argv.port}`)
}
})
.catch((err) => {
console.error(err)
process.exit(1)
})