Socket
Socket
Sign inDemoInstall

osenv

Package Overview
Dependencies
2
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    osenv

Look up environment settings specific to different operating systems


Version published
Weekly downloads
3.7M
decreased by-15.16%
Maintainers
4
Install size
13.6 kB
Created
Weekly downloads
 

Package description

What is osenv?

The osenv npm package provides an easy way to access environment settings and paths that are specific to the operating system the code is running on. It abstracts away the differences between operating systems, allowing developers to write more portable code.

What are osenv's main functionalities?

Home Directory

Retrieve the home directory of the current user, which is useful for storing user-specific data or configuration files.

const osenv = require('osenv');
const home = osenv.home();
console.log('Home Directory:', home);

Temporary Directory

Get the path to the temporary directory where temporary files can be stored. This is useful for operations that require temporary file storage.

const osenv = require('osenv');
const tmp = osenv.tmpdir();
console.log('Temporary Directory:', tmp);

User's Shell

Access the shell environment used by the current user. This can be important for scripts that need to execute shell commands.

const osenv = require('osenv');
const shell = osenv.shell();
console.log('User Shell:', shell);

Other packages similar to osenv

Readme

Source

osenv

Look up environment settings specific to different operating systems.

Usage

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.

osenv.editor()

Return the executable name of the editor program. This uses the EDITOR and VISUAL environment variables, and falls back to vi on Unix, or notepad.exe on Windows.

osenv.shell()

The SHELL on Unix, which Windows calls the ComSpec. Defaults to 'bash' or 'cmd'.

Keywords

FAQs

Last updated on 16 Feb 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc