forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnext-start
executable file
·50 lines (42 loc) · 1.04 KB
/
next-start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
import { resolve } from 'path'
import parseArgs from 'minimist'
import Server from '../server'
const argv = parseArgs(process.argv.slice(2), {
alias: {
h: 'help',
p: 'port'
},
boolean: ['h'],
default: {
p: 3000
}
})
if (argv.help) {
console.log(`
Description
Starts the application in production mode.
The application should be compiled with \`next build\` first.
Usage
$ next start <dir> -p <port>
<dir> is the directory that contains the compiled .next folder
created by running \`next build\`.
If no directory is provided, the current directory will be assumed.
Options
--port, -p A port number on which to start the application
--help, -p Displays this message
`)
process.exit(0)
}
const dir = resolve(argv._[0] || '.')
const srv = new Server({ dir })
srv.start(argv.port)
.then(() => {
if (!process.env.NOW) {
console.log(`> Ready on http://localhost:${argv.port}`)
}
})
.catch((err) => {
console.error(err)
process.exit(1)
})