Skip to content

Commit

Permalink
docs(readme): clarify that npmEnv overwrites process.env
Browse files Browse the repository at this point in the history
  • Loading branch information
carlgieringer authored and nicojs committed Nov 21, 2018
1 parent aeaa4da commit 1c42b96
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,20 @@ If you want the progress reporting like the CLI has: use `progress(localInstalle

##### Passing npm env variables

In some cases it might be useful to pass some custom env variables object to npm. For example when you want npm to rebuild native node modules against Electron headers. You can do it by passing `options` to `LocalInstaller`'s constructor.
In some cases it might be useful to control the env variables for npm. For example when you want npm to rebuild native node modules against Electron headers. You can do it by passing `options` to `LocalInstaller`'s constructor.

```javascript
const localInstaller = new LocalInstaller(
{ '.': ['../sibling'] },
{ npmEnv: { envVar: 'envValue' } }
);
```
```

Because the value provided for `npmEnv` will override the environment of the npm execution, you may want to extend the existing environment so that required values such as `PATH` are preserved:

```javascript
const localInstaller = new LocalInstaller(
{ '.': ['../sibling'] },
{ npmEnv: Object.assign({}, process.env, { envVar: 'envValue' }) }
);
```

0 comments on commit 1c42b96

Please sign in to comment.