netrc-parser
Advanced tools
Comparing version 3.0.3 to 3.1.0
@@ -31,3 +31,3 @@ import * as Token from './token'; | ||
*/ | ||
save(): Promise<void>; | ||
save(): Promise<{}>; | ||
/** | ||
@@ -51,3 +51,2 @@ * save the current home netrc with any changes | ||
private readonly homedir; | ||
private defaultFileSync(); | ||
private defaultFile(); | ||
@@ -54,0 +53,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const fs = require("fs-extra"); | ||
const fs = require("fs"); | ||
const os = require("os"); | ||
const path = require("path"); | ||
const execa = require("execa"); | ||
const lex_1 = require("./lex"); | ||
const Token = require("./token"); | ||
@@ -67,3 +65,3 @@ let _debug; | ||
if (!this._file) | ||
this._file = this.defaultFileSync(); | ||
this._file = this.defaultFile(); | ||
this.parse(this.readFileSync()); | ||
@@ -103,8 +101,11 @@ } | ||
if (this.file.endsWith('.gpg')) { | ||
const execa = require('execa'); | ||
const { stdout, code } = yield execa('gpg', this.gpgEncryptArgs, { input: body, stdio: [null, null, 2] }); | ||
if (code !== 0) | ||
if (code) | ||
throw new Error(`gpg exited with code ${code}`); | ||
body = stdout; | ||
} | ||
yield fs.writeFile(this.file, body, { mode: 0o600 }); | ||
return new Promise((resolve, reject) => { | ||
fs.writeFile(this.file, body, { mode: 0o600 }, err => (err ? reject(err) : resolve())); | ||
}); | ||
}); | ||
@@ -114,4 +115,5 @@ } | ||
if (this.file.endsWith('.gpg')) { | ||
const { stdout, status } = execa.sync('gpg', this.gpgEncryptArgs, { input: body, stdio: [null, null, 2] }); | ||
if (status !== 0) | ||
const execa = require('execa'); | ||
const { stdout, code } = execa.sync('gpg', this.gpgEncryptArgs, { input: body, stdio: [null, null, 2] }); | ||
if (code) | ||
throw new Error(`gpg exited with code ${status}`); | ||
@@ -123,3 +125,4 @@ body = stdout; | ||
parse(body) { | ||
const tokens = lex_1.default(body); | ||
let lex = require('./lex').default; | ||
const tokens = lex(body); | ||
let cur = this; | ||
@@ -154,2 +157,3 @@ for (let token of tokens) { | ||
const decryptFile = () => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const execa = require('execa'); | ||
const { code, stdout } = yield execa('gpg', this.gpgDecryptArgs, { stdio }); | ||
@@ -163,10 +167,9 @@ if (code !== 0) | ||
else { | ||
try { | ||
return yield fs.readFile(this.file, 'utf8'); | ||
} | ||
catch (err) { | ||
if (err.code !== 'ENOENT') | ||
throw err; | ||
return ''; | ||
} | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(this.file, { encoding: 'utf8' }, (err, data) => { | ||
if (err && err.code !== 'ENOENT') | ||
reject(err); | ||
resolve(data || ''); | ||
}); | ||
}); | ||
} | ||
@@ -177,4 +180,5 @@ }); | ||
const decryptFile = () => { | ||
const execa = require('execa'); | ||
const { stdout, status } = execa.sync('gpg', this.gpgDecryptArgs, { stdio }); | ||
if (status !== 0) | ||
if (status) | ||
throw new Error(`gpg exited with code ${status}`); | ||
@@ -204,14 +208,8 @@ return stdout; | ||
} | ||
defaultFileSync() { | ||
defaultFile() { | ||
let file = path.join(this.homedir, os.platform() === 'win32' ? '_netrc' : '.netrc'); | ||
return fs.pathExistsSync(file + '.gpg') ? (file += '.gpg') : file; | ||
return fs.existsSync(file + '.gpg') ? (file += '.gpg') : file; | ||
} | ||
defaultFile() { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
let file = path.join(this.homedir, os.platform() === 'win32' ? '_netrc' : '.netrc'); | ||
return (yield fs.pathExists(file + '.gpg')) ? (file += '.gpg') : file; | ||
}); | ||
} | ||
} | ||
exports.Netrc = Netrc; | ||
exports.default = new Netrc(); |
{ | ||
"name": "netrc-parser", | ||
"description": "netrc parser", | ||
"version": "3.0.3", | ||
"version": "3.1.0", | ||
"author": "Jeff Dickey (@jdxcode)", | ||
"bugs": "https://github.com/jdxcode/node-netrc-parser/issues", | ||
"dependencies": { | ||
"execa": "^0.8.0", | ||
"fs-extra": "^5.0.0", | ||
"graceful-fs": "^4.1.11", | ||
"execa": "^0.9.0", | ||
"lex": "^1.7.9" | ||
}, | ||
"devDependencies": { | ||
"@heroku-cli/tslint": "^1.1.2", | ||
"@heroku-cli/tslint": "^1.1.4", | ||
"@types/execa": "^0.8.1", | ||
"@types/fs-extra": "^5.0.0", | ||
"@types/graceful-fs": "^4.1.2", | ||
"@types/jest": "^22.0.1", | ||
"@types/jest": "^22.1.1", | ||
"debug": "^3.1.0", | ||
"jest": "22.0.4", | ||
"prettier": "^1.9.2", | ||
"ts-jest": "^22.0.1", | ||
"tslint": "^5.8.0", | ||
"typescript": "^2.6.2" | ||
"jest": "22.1.4", | ||
"ts-jest": "^22.0.3", | ||
"tslint": "^5.9.1", | ||
"typescript": "^2.7.1" | ||
}, | ||
@@ -37,3 +34,2 @@ "files": [ | ||
"scripts": { | ||
"posttest": "prettier -l src/**/*.ts", | ||
"prepare": "tsc", | ||
@@ -40,0 +36,0 @@ "pretest": "tsc", |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
2
10
53967
1377
+ Addedexeca@0.9.0(transitive)
- Removedfs-extra@^5.0.0
- Removedgraceful-fs@^4.1.11
- Removedexeca@0.8.0(transitive)
- Removedfs-extra@5.0.0(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedjsonfile@4.0.0(transitive)
- Removeduniversalify@0.1.2(transitive)
Updatedexeca@^0.9.0