Skip to content

Commit f9e28d8

Browse files
committed
fix: don't fail with --watch
1 parent 15d38f9 commit f9e28d8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/bin.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,16 @@ const { values, positionals } = parseArgs({
3737
version: {
3838
type: 'boolean',
3939
},
40+
// Deprecated
41+
watch: {
42+
type: 'boolean',
43+
short: 'w',
44+
},
4045
},
4146
allowPositionals: true,
4247
})
4348

49+
// --help
4450
if (values.help || positionals.length === 0) {
4551
console.log(`Usage: json-server [options] <file>
4652
Options:
@@ -52,6 +58,7 @@ Options:
5258
process.exit()
5359
}
5460

61+
// --version
5562
if (values.version) {
5663
const pkg = JSON.parse(
5764
readFileSync(join(__dirname, '../package.json'), 'utf8'),
@@ -60,6 +67,15 @@ if (values.version) {
6067
process.exit()
6168
}
6269

70+
// Handle --watch
71+
if (values.watch) {
72+
console.log(
73+
chalk.yellow(
74+
'--watch/-w can be omitted, JSON Server 1+ watches for file changes by default',
75+
),
76+
)
77+
}
78+
6379
// App args and options
6480
const file = positionals[0] ?? ''
6581
const port = parseInt(values.port ?? process.env['PORT'] ?? '3000')

0 commit comments

Comments
 (0)