Skip to content

Commit d9b1828

Browse files
impronunciablerauchg
authored andcommitted
Added warning when pages dir is not present (#14)
* Added warning when pages dir is not present and a special one if it exists as a sibling of the project root * Added requested copy changes
1 parent 2d06eb5 commit d9b1828

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

bin/next-dev

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/env node
2-
3-
import { resolve } from 'path'
2+
import { resolve, join } from 'path'
43
import parseArgs from 'minimist'
54
import Server from '../server'
65
import build from '../server/build'
6+
import { exists } from 'mz/fs'
77

88
const argv = parseArgs(process.argv.slice(2), {
99
alias: {
@@ -23,6 +23,15 @@ build(dir)
2323
const srv = new Server({ dir, dev: true })
2424
await srv.start(argv.port)
2525
console.log('> Ready on http://localhost:%d', argv.port)
26+
27+
// Check if pages dir exists and warn if not
28+
if (!await exists(join(dir, 'pages'))) {
29+
if (await exists(join(dir, '..', 'pages'))) {
30+
console.warn('> No `pages` directory found. Did you mean to run `next` in the parent (`../`) directory?')
31+
} else {
32+
console.warn('> Couldn\'t find a `pages` directory. Please create one under the project root')
33+
}
34+
}
2635
})
2736
.catch((err) => {
2837
console.error(err)

0 commit comments

Comments
 (0)