UNPKG

911 BMarkdownView Raw
1netrc [![Build Status](https://travis-ci.org/camshaft/netrc.png?branch=master)](https://travis-ci.org/camshaft/netrc)
2=====
3
4Parse netrc files
5
6Usage
7-----
8
9```js
10var netrc = require('netrc');
11
12var myNetrc = netrc();
13
14console.log(myNetrc['github.com'])
15// { login: 'my-oauth-token',
16// password: 'x-oauth-basic' }
17
18myNetrc['github.com'].login = 'my-new-oauth-token';
19
20netrc.save(myNetrc);
21```
22
23API
24---
25
26### netrc([file])
27
28Loads a `.netrc` file, defaulting to `~/.netrc`
29
30### netrc.parse(string)
31
32Parses netrc formatted string into an object:
33
34```json
35{
36 "machine1.example.com": {
37 "login": "my-login",
38 "password": "my-password"
39 },
40 "machine2.example.com": {
41 "login": "my-other-login",
42 "password": "my-other-password"
43 }
44}
45```
46
47### netrc.format(object)
48
49Formats a netrc object into a valid string
50
51### netrc.save(object)
52
53Persists a netrc object to `~/.netrc`
54
55## Tests
56
57```
58$ npm test
59```