netrc-parser
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -15,6 +15,2 @@ 'use strict'; | ||
var _getIterator2 = require('babel-runtime/core-js/get-iterator'); | ||
var _getIterator3 = _interopRequireDefault(_getIterator2); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -94,34 +90,20 @@ | ||
function machineProxy(machine) { | ||
var tokens = machine._tokens; | ||
var props = function props() { | ||
return tokens.filter(function (t) { | ||
return machine._tokens.filter(function (t) { | ||
return t.type === 'prop'; | ||
}); | ||
}; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = (0, _getIterator3.default)(props()), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var prop = _step.value; | ||
var loadProps = function loadProps() { | ||
return props().forEach(function (prop) { | ||
machine[prop.name] = prop.value; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
}); | ||
}; | ||
loadProps(); | ||
return new Proxy(machine, { | ||
set: function set(machine, name, value) { | ||
if (name === '_tokens') { | ||
machine._tokens = value; | ||
loadProps(); | ||
return true; | ||
} | ||
machine[name] = value; | ||
@@ -132,8 +114,8 @@ var prop = props().find(function (p) { | ||
if (prop) prop.value = value;else { | ||
var lastPropIdx = findIndex(tokens, function (t) { | ||
var lastPropIdx = findIndex(machine._tokens, function (t) { | ||
return t.type === 'prop'; | ||
}); | ||
var whitespace = lastPropIdx === -1 ? { type: 'whitespace', content: '\n ' } : tokens[lastPropIdx - 1]; | ||
tokens.splice(lastPropIdx, 0, whitespace); // insert whitespace | ||
tokens.splice(lastPropIdx, 0, { type: 'prop', name: name, value: value }); | ||
var whitespace = lastPropIdx === -1 ? { type: 'whitespace', content: '\n ' } : machine._tokens[lastPropIdx - 1]; | ||
machine._tokens.splice(lastPropIdx, 0, whitespace); // insert whitespace | ||
machine._tokens.splice(lastPropIdx, 0, { type: 'prop', name: name, value: value }); | ||
} | ||
@@ -156,3 +138,5 @@ return true; | ||
get: function get(machines, host) { | ||
return machines[host] || {}; | ||
if (typeof host !== 'string') return machines[host]; | ||
if (!machines[host]) machines[host] = addNewMachine(host); | ||
return machines[host]; | ||
}, | ||
@@ -276,4 +260,3 @@ set: function set(machines, host, value) { | ||
var _host = tokens[_i].value; | ||
_this.machines[_host] = { type: 'machine', _tokens: getMachineTokens() }; | ||
_this._tokens.push(_this.machines[_host]); | ||
_this.machines[_host]._tokens = getMachineTokens(); | ||
break; | ||
@@ -280,0 +263,0 @@ default: |
{ | ||
"name": "netrc-parser", | ||
"description": "netrc parser", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"author": "Jeff Dickey (@dickeyxxx)", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/dickeyxxx/node-netrc-parser/issues", |
@@ -12,3 +12,3 @@ # netrc-parser | ||
[src/netrc.js:165-264](https://github.com/dickeyxxx/node-netrc-parser/blob/a9fe7c9efd14e971c0ee03dcf36a6c1ebf832bd0/src/netrc.js#L165-L264 "Source code on GitHub") | ||
[src/netrc.js:172-270](https://github.com/dickeyxxx/node-netrc-parser/blob/a0f1bf1304d5961e1cdb08a70455f89eb32bd537/src/netrc.js#L172-L270 "Source code on GitHub") | ||
@@ -19,3 +19,3 @@ parses a netrc file | ||
[src/netrc.js:172-172](https://github.com/dickeyxxx/node-netrc-parser/blob/a9fe7c9efd14e971c0ee03dcf36a6c1ebf832bd0/src/netrc.js#L172-L172 "Source code on GitHub") | ||
[src/netrc.js:179-179](https://github.com/dickeyxxx/node-netrc-parser/blob/a0f1bf1304d5961e1cdb08a70455f89eb32bd537/src/netrc.js#L179-L179 "Source code on GitHub") | ||
@@ -35,3 +35,3 @@ gets the machines on the home netrc file | ||
[src/netrc.js:181-181](https://github.com/dickeyxxx/node-netrc-parser/blob/a9fe7c9efd14e971c0ee03dcf36a6c1ebf832bd0/src/netrc.js#L181-L181 "Source code on GitHub") | ||
[src/netrc.js:188-188](https://github.com/dickeyxxx/node-netrc-parser/blob/a0f1bf1304d5961e1cdb08a70455f89eb32bd537/src/netrc.js#L188-L188 "Source code on GitHub") | ||
@@ -38,0 +38,0 @@ save the current home netrc with any changes |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17541
238