How to use shell-env - 7 common examples

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 appium / appium-desktop / app / main.js View on Github external
import rebuildMenus from './main/menus';
import shellEnv from 'shell-env';
import fixPath from 'fix-path';
import settings from './shared/settings';

let mainWindow = null;
const isDev = process.env.NODE_ENV === 'development';

if (isDev) {
  require('electron-debug')(); // eslint-disable-line global-require
}

if (!isDev) {
  // if we're running from the app package, we won't have access to env vars
  // normally loaded in a shell, so work around with the shell-env module
  const decoratedEnv = shellEnv.sync();
  process.env = {...process.env, ...decoratedEnv};

  // and we need to do the same thing with PATH
  fixPath();
}
setSavedEnv();

app.on('window-all-closed', () => {
  app.quit();
});


const installExtensions = async () => {
  if (isDev) {
    const installer = require('electron-devtools-installer'); // eslint-disable-line global-require
    const extensions = [
github eko / monday-app / main.js View on Github external
app.on('ready', () => {
    global.sharedObject = {
        isDarkMode: 'darwin' == process.platform ? systemPreferences.isDarkMode() : false
    }

    const envVars = shellEnv.sync()

    // Ask for root permissions
    const serverpath = path.join(__dirname, 'dist', 'monday-server')
    sudo.exec(`${serverpath} &`, {
        name: 'Monday',
        env: {
            'HOME': envVars.HOME || '',
            'GOPATH': envVars.GOPATH || '',
            'MONDAY_CONFIG_PATH': envVars.MONDAY_CONFIG_PATH || '',
            'MONDAY_KUBE_CONFIG': envVars.MONDAY_KUBE_CONFIG || '',
            'PATH': envVars.PATH || '',
            'TERM': 'xterm',
        },
    },
        function (error, stdout, stderr) {
            if (error) throw error
github zhuzhuyule / HexoEditor / app / index.js View on Github external
*  (at your option) any later version.
 *
 *  Moeditor is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Moeditor. If not, see .
 */

'use strict';

// on darwin, to rewrite path
if (process.platform === "darwin") {
    const shellEnvs = require('shell-env').sync()
    process.env.PATH = shellEnvs.PATH;
}

const app = require('electron').app,
      MoeditorApplication = require('./moe-app');

var moeApp = null, openFile = null;

app.on("ready", () => {
    moeApp = new MoeditorApplication();
    global.moeApp = moeApp;
    global.app = app;
    app.moeApp = moeApp;
    if (openFile !== null)
        moeApp.osxOpenFile = openFile;
	moeApp.run();
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 sindresorhus / shell-path / index.js View on Github external
module.exports.sync = () => shellEnv.sync().PATH;
github Semibold / Fullscreen / webpack.config.js View on Github external
const path = require("path");
const rimraf = require("rimraf");
const webpack = require("webpack");
const shell = require("shell-env");
const git = require("git-rev-sync");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const EventHooksPlugin = require("event-hooks-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");

const manifest = require("./package.json");

const shellEnv = Object(shell.sync());
const webpackPath = path.resolve(__dirname, "dist/webpack");
const releasePath = path.resolve(__dirname, "dist/release");

/**
 * @readonly
 * @desc Webpack/Custom Command Line Interface
 */
class CustomDefaultConfig {
    static get argv() {
        return {
            mode: "production",
            devtool: false,
        };
    }

    static get 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

57 / 100
Full package analysis

Popular shell-env functions