Skip to content

Commit

Permalink
fix: 🐛 macos mac fix (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
raduachim authored Jan 16, 2020
1 parent 6ce483d commit 1c49511
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/tunnel.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ async function start ({ port, subdomain, unsafe, mac, open, ...cmd }) {
process.exit(0)
}
if (mac) {
subdomain = Object.values(networkInterfaces())
.reduce((a1, a2) => a1.concat(a2))
.find(i => i.mac !== '00:00:00:00:00:00').mac
.replace(/:/g, '')
subdomain = Buffer.from(
Object.values(networkInterfaces())
.reduce((a1, a2) => a1.concat(a2))
.find(i => i.mac !== '00:00:00:00:00:00')
.mac.replace(/:/g, '')
)
.toString('base64')
.toLowerCase()
.replace(/=\+/g, '')
}
try {
const config = { port, subdomain }
Expand All @@ -26,7 +31,7 @@ async function start ({ port, subdomain, unsafe, mac, open, ...cmd }) {
tunnel.url = tunnel.url.replace('https://', 'http://')
}
log(`Opening tunnel on ${tunnel.url}`)
tunnel.on('error', (error) => console.log(error))
tunnel.on('error', error => console.log(error))

const [command, ...args] = Object.values(cmd)
const env = {
Expand All @@ -35,8 +40,7 @@ async function start ({ port, subdomain, unsafe, mac, open, ...cmd }) {
OPERATOR_URL: 'https://operator-test.dev.services.jtech.se',
PORT: port
}
const spawnCommand = Object
.entries(env)
const spawnCommand = Object.entries(env)
.map(([prop, val]) => `${prop}=${val}`)
.concat([command])
.concat(args)
Expand All @@ -50,10 +54,10 @@ async function start ({ port, subdomain, unsafe, mac, open, ...cmd }) {
stdio: 'pipe'
})
if (open) {
ls.stdout.once('data', (data) => opn(tunnel.url))
ls.stdout.once('data', data => opn(tunnel.url))
}
ls.stdout.on('data', (data) => process.stdout.write(data))
ls.stderr.on('data', (data) => process.stderr.write(data))
ls.stdout.on('data', data => process.stdout.write(data))
ls.stderr.on('data', data => process.stderr.write(data))
ls.on('error', exitOnError)
ls.on('close', () => process.stdout.write('\n'))
} catch (error) {
Expand Down

0 comments on commit 1c49511

Please sign in to comment.