generate-ssh
Advanced tools
Comparing version 0.0.1 to 0.0.2
35
index.js
"use strict"; | ||
var os = require("os"); | ||
var path = require("path"); | ||
@@ -28,6 +27,4 @@ var fs = require("fs"); | ||
cb(null, loc); | ||
} else if (paths.length !== 0) { | ||
} else { | ||
findValidExecutable(paths, cb); | ||
} else { | ||
cb(new Error("Couldn't locate executable at given paths.")); | ||
} | ||
@@ -37,2 +34,7 @@ }); | ||
function cleanup(keyPath) { | ||
fs.unlink(keyPath, function () { }); | ||
fs.unlink(keyPath + ".pub", function () { }); | ||
} | ||
module.exports.locate = function (searchPaths, cb) { | ||
@@ -96,5 +98,3 @@ var cmd = "ssh-keygen"; | ||
cp.on("error", function () { | ||
fs.unlink(keyPath, function () { }); | ||
fs.unlink(keyPath + ".pub", function () { }); | ||
cleanup(keyPath); | ||
if (done) return; | ||
@@ -107,6 +107,4 @@ | ||
cp.on("close", function (code, signal) { | ||
if (done) { | ||
fs.unlink(keyPath, function () { }); | ||
fs.unlink(keyPath + ".pub", function () { }); | ||
if (done) { | ||
cleanup(keyPath); | ||
return; | ||
@@ -118,5 +116,4 @@ } | ||
fs.readFile(keyPath, { encoding: "utf8" }, function (err, privateKey) { | ||
if (err) { | ||
fs.unlink(keyPath, function () { }); | ||
fs.unlink(keyPath + ".pub", function () { }); | ||
if (err) { | ||
cleanup(keyPath); | ||
done = true; | ||
@@ -128,5 +125,4 @@ | ||
fs.readFile(keyPath + ".pub", { encoding: "utf8" }, function (err, publicKey) { | ||
if (err) { | ||
fs.unlink(keyPath, function () { }); | ||
fs.unlink(keyPath + ".pub", function () { }); | ||
if (err) { | ||
cleanup(keyPath); | ||
done = true; | ||
@@ -137,5 +133,4 @@ | ||
done = true; | ||
fs.unlink(keyPath, function () { }); | ||
fs.unlink(keyPath + ".pub", function () { }); | ||
done = true; | ||
cleanup(keyPath); | ||
@@ -142,0 +137,0 @@ cb(null, { |
{ | ||
"name": "generate-ssh", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"author": "Sebastian Mayr <npm@smayr.name>", | ||
@@ -5,0 +5,0 @@ "description": "A wrapper around ssh-keygen", |
@@ -1,5 +0,2 @@ | ||
generate-ssh | ||
### | ||
generate-ssh is a small wrapper around the ssh-keygen tool. | ||
generate-ssh is a small wrapper around the ssh-keygen tool. | ||
It supports proper error handling, doesn't call the callback multiple times (:<) and has some support for locating the ssh-keygen executable on Windows. | ||
@@ -6,0 +3,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
5144
107
19