Skip to content

Commit 877840b

Browse files
hacdiasachingbrain
authored andcommitted
feat: support config files (#102)
* feat: support config files License: MIT Signed-off-by: Henrique Dias <[email protected]> * feat: update pkg name License: MIT Signed-off-by: Henrique Dias <[email protected]> * feat: do not hardcode pkg name License: MIT Signed-off-by: Henrique Dias <[email protected]> * docs: remove repeated sentence License: MIT Signed-off-by: Henrique Dias <[email protected]>
1 parent ac6bfd7 commit 877840b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,15 @@ Options:
119119
unavailable
120120
[default: "https://registry.npmjs.com"]
121121
```
122+
123+
## Configuration File
124+
125+
We use [`rc`](https://github.com/dominictarr/rc) to parse configuration files. Please see the [`rc` repository](https://github.com/dominictarr/rc#standards) for the order of precedence used when searching for configuration files. Our app is `ipfs-npm`.
126+
127+
For instance, if you want to always use a remote daemon, you could create a `~/.ipfs-npmrc` file like this:
128+
129+
```json
130+
{
131+
"ipfsNode": "/ip4/127.0.0.1/tcp/5001"
132+
}
133+
```

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"ipfsd-ctl": "~0.42.2",
4747
"ipfs-registry-mirror-common": "^1.0.13",
4848
"once": "^1.4.0",
49+
"rc": "^1.2.8",
4950
"request": "^2.88.0",
5051
"request-promise": "^4.2.4",
5152
"which-promise": "^1.0.0",

src/cli/bin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ require('dnscache')({ enable: true })
77
const pkg = require('../../package')
88
const path = require('path')
99
const os = require('os')
10+
const rc = require('rc')
1011

1112
process.title = pkg.name
1213

1314
const yargs = require('yargs')
15+
.config(rc(pkg.name, null, {}))
1416

1517
yargs.command('$0', 'Installs your js dependencies using IPFS', (yargs) => { // eslint-disable-line no-unused-expressions
1618
yargs

0 commit comments

Comments
 (0)