This repository has been archived by the owner on Aug 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 48fd46e
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# osenv | ||
|
||
Look up environment settings specific to different operating systems. | ||
|
||
## 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: | ||
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 | ||
// 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) | ||
}) | ||
``` | ||
|
||
## osenv.hostname() | ||
|
||
The machine name. Calls `hostname` if not found. | ||
|
||
## osenv.user() | ||
|
||
The currently logged-in user. Calls `whoami` if not found. | ||
|
||
## osenv.prompt() | ||
|
||
Either PS1 on unix, or PROMPT on Windows. | ||
|
||
## osenv.tmpdir() | ||
|
||
The place where temporary files should be created. | ||
|
||
## osenv.home() | ||
|
||
No place like it. | ||
|
||
## osenv.path() | ||
|
||
An array of the places that the operating system will search for | ||
executables. |