yaml-crypt
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -32,16 +32,20 @@ #!/usr/bin/env node | ||
} catch (e) { | ||
if (e instanceof ExitError) { | ||
process.exit(e.status); | ||
} else if (e instanceof UsageError || e instanceof UnknownError) { | ||
console.error(`${module.exports.name}: error: ${e.message}`); | ||
process.exit(5); | ||
} else if (e instanceof ConfigurationError) { | ||
console.error(`${module.exports.name}: could not parse configuration: ${e.message}`); | ||
process.exit(6); | ||
} else { | ||
throw e; | ||
} | ||
handleError(e); | ||
} | ||
} | ||
function handleError(e) { | ||
if (e instanceof ExitError) { | ||
process.exit(e.status); | ||
} else if (e instanceof UsageError || e instanceof UnknownError) { | ||
console.error(`${module.exports.name}: error: ${e.message}`); | ||
process.exit(5); | ||
} else if (e instanceof ConfigurationError) { | ||
console.error(`${module.exports.name}: could not parse configuration: ${e.message}`); | ||
process.exit(6); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
function config() { | ||
@@ -329,3 +333,4 @@ const home = `${os.homedir()}/.yaml-crypt`; | ||
} else { | ||
const result = tryDecrypt(opts, keys, crypt => crypt.decryptRaw(buf)); | ||
const str = buf.toString("utf8"); | ||
const result = tryDecrypt(opts, keys, crypt => crypt.decryptRaw(str)); | ||
output.write(result); | ||
@@ -362,3 +367,7 @@ } | ||
if (typeof input === 'string' || input instanceof String || Buffer.isBuffer(input)) { | ||
callback(input); | ||
try { | ||
callback(input); | ||
} catch (e) { | ||
handleError(e); | ||
} | ||
} else { | ||
@@ -375,3 +384,7 @@ const ret = []; | ||
input.on('end', () => { | ||
callback(Buffer.concat(ret, len)); | ||
try { | ||
callback(Buffer.concat(ret, len)); | ||
} catch (e) { | ||
handleError(e); | ||
} | ||
}); | ||
@@ -586,3 +599,3 @@ } | ||
} else { | ||
throw new Error('no matching key to decrypt the given data!'); | ||
throw new UsageError('no matching key to decrypt the given data!'); | ||
} | ||
@@ -589,0 +602,0 @@ } |
{ | ||
"name": "yaml-crypt", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Encrypt and decrypt YAML documents", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -200,3 +200,3 @@ const fs = require('fs'); | ||
const options = { | ||
'stdin': input, | ||
'stdin': Buffer.from(input), | ||
'stdout': new Out() | ||
@@ -203,0 +203,0 @@ }; |
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
55712
1325