Skip to content

Commit

Permalink
udpates README and output in compile
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanpedersen committed Sep 13, 2016
1 parent 293f33d commit 1b23281
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
# heroku-buildpack-npmrc
A Heroku buildpack for overriding the .npmrc file in the build directory with the contents of a config var. Useful for authorizing with npm when installing private packages.

## Configure Multiple Buildpacks
### _Option 1:_ Heroku CLI or Dashboard
Add the buildpack to your Heroku app either using the CLI or the Heroku dashboard. The `heroku-buildpack-npmrc` needs to run before any buildpack using npm. In the following example, it runs before the `heroku/nodejs` buildpack.
```bash
$ heroku buildpacks:set --index 1 https://github.com/debitoor/heroku-buildpack-npmrc.git
$ heroku buildpacks:add heroku/nodejs
```

### _Option 2:_ Use `heroku-buildpack-multi`
Instead of setting the buildpacks directly with Heroku they can also be configured using a `.buildpacks` in combination with [`heroku-buildpack-multi`]( https://github.com/heroku/heroku-buildpack-multi).

``` bash
$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-multi.git
```

The same example given for the CLI use would have the following `.buildpacks` file.

``` bash
$ cat .buildpacks
https://github.com/debitoor/heroku-buildpack-npmrc.git
https://github.com/heroku/heroku-buildpack-nodejs.git
```

## Configure Config Var
Add the NPMRC config var in Heroku with the contents of your .npmrc file.

``` bash
$ heroku config:set NPMRC=//registry.npmjs.org/:_authToken=00000000-0000-0000-0000-000000000000
```
4 changes: 1 addition & 3 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ build_dir=${1:-}
npmrc="$(cat $ENV_DIR/NPMRC)"

if [ "$npmrc" != "" ]; then
echo "-----> Using NPMRC"
echo "-----> Using .npmrc from config var NPMRC"
echo "$npmrc" > "$build_dir/.npmrc"
exit 0
else
echo "-----> No NPMRC"
fi

0 comments on commit 1b23281

Please sign in to comment.