1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Only watch config file that exists on the level of source files (#1643)

This commit is contained in:
Kevin Donahue 2017-04-10 10:07:38 -04:00 committed by Leo Lamprecht
parent 0ed3978a51
commit c9bfba6865

View file

@ -1,9 +1,10 @@
#!/usr/bin/env node #!/usr/bin/env node
import { join } from 'path' import { join, resolve } from 'path'
import { spawn } from 'cross-spawn' import { spawn } from 'cross-spawn'
import { watchFile } from 'fs' import { watchFile } from 'fs'
import pkg from '../../package.json' import pkg from '../../package.json'
import getConfig from '../server/config'
if (pkg.peerDependencies) { if (pkg.peerDependencies) {
Object.keys(pkg.peerDependencies).forEach(dependency => { Object.keys(pkg.peerDependencies).forEach(dependency => {
@ -78,9 +79,10 @@ const startProcess = () => {
} }
let proc = startProcess() let proc = startProcess()
const { pagesDirectory = resolve(process.cwd(), 'pages') } = getConfig(process.cwd())
if (cmd === 'dev') { if (cmd === 'dev') {
watchFile(join(process.cwd(), 'next.config.js'), (cur, prev) => { watchFile(`${resolve(pagesDirectory, '..')}/next.config.js`, (cur, prev) => {
if (cur.size > 0 || prev.size > 0) { if (cur.size > 0 || prev.size > 0) {
console.log('\n> Found a change in next.config.js, restarting the server...') console.log('\n> Found a change in next.config.js, restarting the server...')
// Don't listen to 'close' now since otherwise parent gets killed by listener // Don't listen to 'close' now since otherwise parent gets killed by listener