Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Commit 52f7e06

Browse files
committed
Fix tunnel logging.
Signed-off-by: David Calavera <[email protected]>
1 parent ae687ea commit 52f7e06

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/commands/dev/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class DevCommand extends Command {
145145

146146
let url;
147147
if (flags.live) {
148-
const liveSession = await createTunnel(site.id, accessToken)
148+
const liveSession = await createTunnel(site.id, accessToken, this.log)
149149
url = liveSession.session_url
150150
process.env.BASE_URL = url
151151

src/live-tunnel.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ const path = require('path')
55
const { fetchLatest } = require('gh-release-fetch')
66
const { runProcess } = require('./run-process')
77

8-
async function createTunnel(siteId, netlifyApiToken) {
9-
await installTunnelClient()
8+
async function createTunnel(siteId, netlifyApiToken, log) {
9+
await installTunnelClient(log)
1010

11-
console.log('Creating Live tunnel')
11+
log('Creating Live tunnel')
1212
const url = `https://api.netlify.com/api/v1/live_sessions?site_id=${siteId}`
1313

1414
const response = await fetch(url, {
@@ -31,23 +31,23 @@ async function createTunnel(siteId, netlifyApiToken) {
3131

3232
async function connectTunnel(session, netlifyApiToken, localPort, log, error) {
3333
const execPath = path.join(os.homedir(), '.netlify', 'tunnel', 'bin', 'live-tunnel-client')
34-
35-
const proc = {
36-
cmd: execPath,
37-
args: ['connect', '-s', session.id, '-t', netlifyApiToken, '-l', localPort]
34+
const args = ['connect', '-s', session.id, '-t', netlifyApiToken, '-l', localPort]
35+
if (process.env.DEBUG) {
36+
args.push('-v')
3837
}
3938

40-
runProcess(cmd, log, error)
39+
log(execPath, args)
40+
runProcess({ cmd: execPath, args: args }, log, error)
4141
}
4242

43-
async function installTunnelClient() {
43+
async function installTunnelClient(log) {
4444
const binPath = path.join(os.homedir(), '.netlify', 'tunnel', 'bin')
4545
const execPath = path.join(binPath, 'live-tunnel-client')
4646
if (execExist(execPath)) {
4747
return
4848
}
4949

50-
console.log('Installing Live Tunnel Client')
50+
log('Installing Live Tunnel Client')
5151

5252
const win = isWindows()
5353
const platform = win ? 'windows' : process.platform

0 commit comments

Comments
 (0)