Osenv

osenv

Look up environment settings.

osenv a tiny util that which has about 6,294,826 weekly downloads on npm, helps us in fetching the required evn setting from process.env acorss OS.

Get it: npm installl osenv

Sample usage:

1
2
3
4
5
6
7
8
9
> require('osenv')
{ user: [Function],
  prompt: [Function],
  hostname: [Function],
  tmpdir: [Function],
  home: [Function],
  path: [Function],
  editor: [Function],
  shell: [Function] }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const osenv = require('osenv')
const path = osenv.path()
const user = osenv.user()
// etc.

// Some things are not reliably in the env, and have a fallback command:
let h = osenv.hostname(function (er, hostname) {
  h = hostname
})
// This will still cause it to be memoized, so calling osenv.hostname()
// is now an immediate operation.

// You can always send a cb, which will get called in the nextTick
// if it's been memoized, or wait for the fallback data if it wasn't
// found in the environment.
osenv.hostname(function (er, hostname) {
  if (er) console.error('error looking up hostname')
  else console.log('this machine calls itself %s', hostname)
})

GIF FTW!

osenv

Suggest a module

Comments