generated from crashmax-dev/node-esm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dev.js
35 lines (33 loc) · 1.05 KB
/
dev.js
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
#!/usr/bin/env node
import ngrok from 'ngrok'
import nodemon from 'nodemon'
ngrok
.connect({
proto: 'http',
addr: process.env.SERVER_PORT
})
.then((url) => {
console.log(`ngrok tunnel opened at: ${url}`)
nodemon({
watch: ['src', '.env'],
ignore: ['db/**'],
exec: `cross-env TS_NODE_TRANSPILE_ONLY=true NGROK_URL=${url} NODE_ENV=development DEBUG=grammy* node --no-warnings --loader ts-node/esm --enable-source-maps --trace-warnings --inspect=0.0.0.0:9234 --nolazy src/index.ts`,
ext: 'ts'
})
.on('start', () => {
console.log('The application has started')
})
.on('restart', (files) => {
console.group('Application restarted due to:')
files.forEach((file) => console.log(file))
console.groupEnd()
})
.on('quit', () => {
console.log('The application has quit, closing ngrok tunnel')
ngrok.kill().then(() => process.exit(0))
})
})
.catch((error) => {
console.error('Error opening ngrok tunnel: ', error)
process.exitCode(1)
})