Skip to content

Commit 84c1462

Browse files
committed
Initial clone of nodenv-default-packages with appropriate modifications
Why: * Handling of root `npmrc` files with `nodenv` seems to be a hassle
0 parents  commit 84c1462

File tree

6 files changed

+137
-0
lines changed

6 files changed

+137
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Timo Sand
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# nodenv-default-npmrc
2+
3+
This nodenv plugin hooks into the `nodenv install` command to automatically
4+
install a `npmrc` file every time you install a new version of Node. It
5+
requires the `node-build` plugin to be installed.
6+
7+
Forked from the excellent [`nodenv-default-packages`][nodenv-default-packages] plugin from
8+
[sstephenson][sstephenson].
9+
10+
## Installation
11+
12+
### Installing as a nodenv plugin
13+
14+
Make sure you have the latest nodenv and node-build versions, then run:
15+
16+
git clone https://github.com/deiga/nodenv-default-npmrc.git $(nodenv root)/plugins/nodenv-default-npmrc
17+
18+
### Installing with Homebrew (for OS X users)
19+
20+
Mac OS X users can install nodenv-default-npmrc with the
21+
[Homebrew](http://brew.sh) package manager.
22+
23+
*This is the recommended method of installation if you installed nodenv
24+
with Homebrew.*
25+
26+
```
27+
$ brew install nodenv/deiga/nodenv-default-npmrc
28+
```
29+
30+
Or, if you would like to install the latest development release:
31+
32+
```
33+
$ brew install --HEAD nodenv/deiga/nodenv-default-npmrc
34+
```
35+
36+
## Usage
37+
38+
nodenv-default-npmrc automatically installs the
39+
`$(nodenv root)/default-npmrc` file to `${PREFIX}/etc/npmrc` every time you successfully install a new
40+
version of Node with `nodenv install`.
41+
42+
43+
## Credits
44+
45+
Forked from [Sam Stephenson][sstephenson]'s [nodenv-default-packages][] by [Timo Sand][deiga].
46+
47+
[sstephenson]: https://github.com/sstephenson
48+
[nodenv-default-packages]: https://github.com/rbenv/nodenv-default-packages
49+
[deiga]: https://github.com/deiga
50+
[nodenv]: https://github.com/nodenv/nodenv
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
if declare -Ff after_install >/dev/null; then
3+
after_install install_default_npmrc
4+
else
5+
echo "nodenv: nodenv-default-npmrc plugin requires node-build" >&2
6+
fi
7+
8+
install_default_npmrc() {
9+
# Only install default npmrc after successfully installing Node.
10+
[ "$STATUS" = "0" ] || return 0
11+
12+
if [ -f "${NODENV_ROOT}/default-npmrc" ]; then
13+
cp "${NODENV_ROOT}/default-npmrc"
14+
fi
15+
}

install.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env sh
2+
# Usage: PREFIX=/usr/local ./install.sh
3+
#
4+
# Installs nodenv-default-npmrc under $PREFIX.
5+
6+
set -e
7+
set -u
8+
9+
cd "$(dirname "$0")"
10+
11+
if [ -z "${PREFIX}" ]; then
12+
PREFIX="/usr/local"
13+
fi
14+
15+
ETC_PATH="${PREFIX}/etc/nodenv.d"
16+
17+
mkdir -p "$ETC_PATH"
18+
19+
cp -RPp etc/nodenv.d/* "$ETC_PATH"

package.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "nodenv-default-npmrc",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "Install default npmrc every time you install a new version of Node",
6+
"homepage": "https://github.com/deiga/nodenv-default-npmrc#readme",
7+
"license": "MIT",
8+
"author": "Timo Sand <[email protected]>",
9+
"contributors": [
10+
],
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/deiga/nodenv-default-npmrc.git"
14+
},
15+
"bugs": {
16+
"url": "https://github.com/deiga/nodenv-default-npmrc/issues"
17+
},
18+
"directories": {
19+
"bin": "bin",
20+
"lib": "libexec",
21+
"test": "test"
22+
},
23+
"scripts": {
24+
"publish:brew": "brew-publish $npm_package_name v$npm_package_version",
25+
"postversion": "git push --follow-tags && npm run publish:brew"
26+
},
27+
"devDependencies": {
28+
"brew-publish": "^2.0.0"
29+
}
30+
}

0 commit comments

Comments
 (0)