Skip to content

Commit 171b544

Browse files
committed
run build before start
1 parent aaedc11 commit 171b544

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

bin/next-start

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#!/usr/bin/env node
22

3-
import { resolve } from 'path'
3+
import { resolve, join } from 'path'
44
import parseArgs from 'minimist'
55
import Server from '../server'
66
import {exists} from 'mz/fs'
7+
import { spawn } from 'cross-spawn'
78

89
const argv = parseArgs(process.argv.slice(2), {
910
alias: {
@@ -40,11 +41,13 @@ const dir = resolve(argv._[0] || '.')
4041

4142
const srv = new Server({ dir })
4243

43-
exists(resolve(process.cwd(), '.next')).then(exists => {
44+
exists(resolve(dir, '.next')).then(exists => {
4445
if (!exists) {
45-
console.error(`> Error! The application should be compiled with \`next build\` first.`)
46-
process.exit(0)
46+
console.log(`> Running \`next build\` first...`)
47+
return spawn.sync(join(__dirname, 'next-build'), { stdio: 'inherit', customFds: [0, 1, 2] })
4748
}
49+
})
50+
.then(() => {
4851
srv.start(argv.port)
4952
})
5053
.then(() => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy