Skip to content

Commit

Permalink
conf: wrap os calls in try catch.
Browse files Browse the repository at this point in the history
There is an os call the tries to read user info, which can fail in
docker base environments. This wraps it in a try catch with a sane
fallback

Semver: patch
  • Loading branch information
esatterwhite committed Jul 3, 2020
1 parent 55b9bc2 commit 83e2312
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ var os = require('os')
, filename = process.argv[1]
;

const {username = 'seeli'} = os.userInfo()
const host = os.hostname()
let username = 'seeli'
let host = 'local'
try {
const info = os.userInfo()
host = os.hostname()
username = info.username
} catch (_) {}

const PS1 = `${username}@${host}`
const name = filename ? path.basename(filename, '.js') : 'seeli'

Expand Down

0 comments on commit 83e2312

Please sign in to comment.