Skip to content

Added warning when pages dir is not present #14

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

Merged
merged 3 commits into from
Oct 17, 2016
Merged
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
13 changes: 11 additions & 2 deletions bin/next-dev
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node

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

const argv = parseArgs(process.argv.slice(2), {
alias: {
Expand All @@ -23,6 +23,15 @@ build(dir)
const srv = new Server({ dir, dev: true })
await srv.start(argv.port)
console.log('> Ready on http://localhost:%d', argv.port)

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