UNPKG

1.47 kBMarkdownView Raw
1# osenv
2
3Look up environment settings specific to different operating systems.
4
5## Usage
6
7```javascript
8var osenv = require('osenv')
9var path = osenv.path()
10var user = osenv.user()
11// etc.
12
13// Some things are not reliably in the env, and have a fallback command:
14var h = osenv.hostname(function (er, hostname) {
15 h = hostname
16})
17// This will still cause it to be memoized, so calling osenv.hostname()
18// is now an immediate operation.
19
20// You can always send a cb, which will get called in the nextTick
21// if it's been memoized, or wait for the fallback data if it wasn't
22// found in the environment.
23osenv.hostname(function (er, hostname) {
24 if (er) console.error('error looking up hostname')
25 else console.log('this machine calls itself %s', hostname)
26})
27```
28
29## osenv.hostname()
30
31The machine name. Calls `hostname` if not found.
32
33## osenv.user()
34
35The currently logged-in user. Calls `whoami` if not found.
36
37## osenv.prompt()
38
39Either PS1 on unix, or PROMPT on Windows.
40
41## osenv.tmpdir()
42
43The place where temporary files should be created.
44
45## osenv.home()
46
47No place like it.
48
49## osenv.path()
50
51An array of the places that the operating system will search for
52executables.
53
54## osenv.editor()
55
56Return the executable name of the editor program. This uses the EDITOR
57and VISUAL environment variables, and falls back to `vi` on Unix, or
58`notepad.exe` on Windows.
59
60## osenv.shell()
61
62The SHELL on Unix, which Windows calls the ComSpec. Defaults to 'bash'
63or 'cmd'.