Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

netrc

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netrc - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

test/fixtures/netrc-same-line

30

index.js

@@ -15,6 +15,8 @@ /**

module.exports = exports = function(file) {
var home = process.env.HOME || process.env.HOMEPATH
, file = file || join(home, ".netrc");
var home = process.env.HOME || process.env.HOMEPATH;
if(!file && !home) return {};
file = file || join(home, ".netrc");
if(!fs.existsSync(file)) return {};
if(!file || !fs.existsSync(file)) return {};
var netrc = fs.readFileSync(file, "UTF-8");

@@ -70,1 +72,23 @@ return exports.parse(netrc);

};
/**
* Generate contents of netrc file from objects.
* @param {Object} machines as returned by `netrc.parse`
* @return {String} text of the netrc file
*/
exports.format = function format(machines){
var lines = [],
keys = Object.getOwnPropertyNames(machines).sort();
keys.forEach(function(key){
lines.push('machine ' + key);
var machine = machines[key];
var attrs = Object.getOwnPropertyNames(machine).sort();
attrs.forEach(function(attr){
if(typeof(machine[attr]) === 'string'){
lines.push(' ' + attr + ' ' + machine[attr]);
}
});
});
return lines.join('\n');
};

2

package.json
{
"name": "netrc",
"version": "0.1.2",
"version": "0.1.3",
"description": "Parse netrc files",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -70,2 +70,21 @@ /**

describe('format', function(){
it('should generate text that parses to the original', function(){
var machines = netrc.parse(valid);
var text = netrc.format(machines);
should.exist(text);
text.should.include('machine github.com');
text.should.include('login CamShaft');
text.should.include('password 123');
var parsed = netrc.parse(text);
parsed.should.have.property('github.com');
parsed["github.com"].should.have.property("login");
parsed["github.com"].login.should.eql("CamShaft");
parsed["github.com"].should.have.property("password");
parsed["github.com"].password.should.eql("123");
});
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc