How to use the shell-env function in shell-env

To help you get started, we’ve selected a few shell-env examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nteract / nteract / applications / desktop / src / main / prepare-env.ts View on Github external
import { ConnectableObservable, from } from "rxjs";
import { first, publishReplay, tap } from "rxjs/operators";
import shellEnv from "shell-env";

// Bring in the current user's environment variables from running a shell session so that
// launchctl on the mac and the windows process manager propagate the proper values for the
// user
//
// TODO: This should be cased off for when the user is already in a proper shell session (possibly launched
//       from the nteract CLI
const env$ = from(shellEnv()).pipe(
  first(),
  tap(env => {
    // no need to change the env if started from the terminal on Mac
    if (
      process.platform !== "darwin" ||
      (process.env != null && process.env.TERM === undefined)
    ) {
      Object.assign(process.env, env);
    }
  }),
  publishReplay(1)
);

(env$ as ConnectableObservable<{}>).connect();

export default env$;
github KELiON / cerebro-shell / src / index.js View on Github external
const getCachedEnv = memoize(() => {
  const ENV = {}
  return shellEnv().then(env => {
    ENV.env = env
    ENV.cwd = env.HOME || `/Users/${process.env.USER}`
    ENV.shell = env.SHELL
    return ENV
  })
}, MEMOIZE_OPTIONS)

shell-env

Get environment variables from the shell

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis

Popular shell-env functions