How to use osenv

Comprehensive osenv code examples:

How to use osenv.prompt:

31
32
33
34
35
36
37
38
39
40

## osenv.user()

The currently logged-in user.  Calls `whoami` if not found.

## osenv.prompt()

Either PS1 on unix, or PROMPT on Windows.

## osenv.tmpdir()

How to use osenv.path:

3
4
5
6
7
8
9
10
11
12

## Usage

```javascript
var osenv = require('osenv')
var path = osenv.path()
var user = osenv.user()
// etc.

// Some things are not reliably in the env, and have a fallback command:

How to use osenv.user:

27
28
29
30
31
32
33
34
35
36

## osenv.hostname()

The machine name.  Calls `hostname` if not found.

## osenv.user()

The currently logged-in user.  Calls `whoami` if not found.

## osenv.prompt()

How to use osenv.hostname:

11
12
13
14
15
16
17
18
19
20

// Some things are not reliably in the env, and have a fallback command:
var 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

How to use osenv.tmpdir:

70
71
72
73
74
75
76
77
78
if (!stableFamily || (+stableFamily.minor % 2)) stableFamily = null
else stableFamily = stableFamily.major + '.' + stableFamily.minor

var defaults

var temp = osenv.tmpdir()
var home = osenv.home()

var uidOrPid = process.getuid ? process.getuid() : process.pid

How to use osenv.editor:

133
134
135
136
137
138
139
140
141
142
color: process.env.NO_COLOR == null,
depth: Infinity,
description: true,
dev: false,
'dry-run': false,
editor: osenv.editor(),
'engine-strict': false,
force: false,

'fetch-retries': 2,

How to use osenv.shell:

216
217
218
219
220
221
222
223
224
225
searchopts: '',
searchexclude: null,
searchlimit: 20,
searchstaleness: 15 * 60,
'send-metrics': false,
shell: osenv.shell(),
shrinkwrap: true,
'sign-git-commit': false,
'sign-git-tag': false,
'sso-poll-frequency': 500,

How to use osenv.home:

71
72
73
74
75
76
77
78
79
80
else stableFamily = stableFamily.major + '.' + stableFamily.minor

var defaults

var temp = osenv.tmpdir()
var home = osenv.home()

var uidOrPid = process.getuid ? process.getuid() : process.pid

if (home) process.env.HOME = home