-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcustom-script.js
More file actions
42 lines (33 loc) · 1.27 KB
/
custom-script.js
File metadata and controls
42 lines (33 loc) · 1.27 KB
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
const execSh = require('exec-sh')
const localtunnel = require('localtunnel')
const killPort = require('kill-port')
const path = require('path')
const envfile = `.env.${process.env.NODE_ENV}`
const envpath = path.resolve(__dirname, envfile)
const request = require('request')
require('dotenv').config({ path: envpath })
const port = process.env.NODE_ENV === 'test' ? 8889 : 8888
killPort(port).then(() => {
console.log('Disable LocalTunnel, run local app')
execSh(`ENV_PATH=${envfile} pipenv run python ./backend/app.py`)
/* request('https://localtunnel.me', (err, res) => {
* if (err) {
* console.log('LocalTunnel is Err..., run local app')
* return execSh(`ENV_PATH=${envfile} pipenv run python ./backend/app.py`)
* }
* const status = res.statusCode
* if (status <400) {
* localtunnel(port, (err, tunnel) => {
* if (err) {
* return console.error(err)
* }
* const baseUrl = tunnel.url
* console.info(baseUrl)
* execSh(`TUNNEL_URL=${baseUrl} ENV_PATH=${envfile} pipenv run python ./backend/app.py`)
* })
* } else {
* console.log('LocalTunnel is Offline, run local app')
* execSh(`ENV_PATH=${envfile} pipenv run python ./backend/app.py`)
* }
* }) */
})