Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added bin/32/msys-2.0.dll
Binary file not shown.
Binary file added bin/32/msys-crypto-1.0.0.dll
Binary file not shown.
Binary file added bin/32/msys-gcc_s-1.dll
Binary file not shown.
Binary file added bin/32/msys-z.dll
Binary file not shown.
Binary file added bin/32/ssh-keygen.exe
Binary file not shown.
Binary file added bin/64/msys-2.0.dll
Binary file not shown.
Binary file added bin/64/msys-crypto-1.0.0.dll
Binary file not shown.
Binary file added bin/64/msys-gcc_s-seh-1.dll
Binary file not shown.
Binary file added bin/64/msys-z.dll
Binary file not shown.
Binary file added bin/64/ssh-keygen.exe
Binary file not shown.
Binary file removed bin/ssh-keygen-32.exe
Binary file not shown.
Binary file removed bin/ssh-keygen-64.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "ssh-keygen",
"version": "0.4.1",
"author": {
"name": "Eric Vicenti",
"url": "http://github.com/ericvicenti"
"name": "Eric Vicenti",
"url": "http://github.com/ericvicenti"
},
"homepage": "http://github.com/ericvicenti/ssh-keygen",
"repository": {
Expand Down
27 changes: 25 additions & 2 deletions src/ssh-keygen.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function binPath() {
if(process.platform !== 'win32') return 'ssh-keygen';

switch(process.arch) {
case 'ia32': return path.join(__dirname, '..', 'bin', 'ssh-keygen-32.exe');
case 'x64': return path.join(__dirname, '..', 'bin', 'ssh-keygen-64.exe');
case 'ia32': return path.join(__dirname, '..', 'bin','32', 'ssh-keygen.exe');
case 'x64': return path.join(__dirname, '..', 'bin', '64', 'ssh-keygen.exe');
}

throw new Error('Unsupported platform');
Expand Down Expand Up @@ -126,3 +126,26 @@ module.exports = function(opts, callback){
ssh_keygen(location, opts, callback);
});
};

module.exports.keygenPromise = function(opts, callback){
return new Promise((resolve , reject) => {
var location = opts.location;
if(!location) location = path.join(os.tmpdir(),'id_rsa');

if(_.isUndefined(opts.read)) opts.read = true;
if(_.isUndefined(opts.force)) opts.force = true;
if(_.isUndefined(opts.destroy)) opts.destroy = false;

checkAvailability(location, opts.force, function(err){
if(err){
log('availability err '+err);
reject(err)
}
ssh_keygen(location, opts, (err, out)=>{
if(err)reject(err)
resolve(out)
});
});
})
};

17 changes: 16 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,19 @@ keygen({
console.log('Done generating key pairs');
console.log(out.key)
console.log(out.pubKey)
});
});


var keygenPromise = require('./src/ssh-keygen').keygenPromise;

keygenPromise({
comment: 'promise@doe.com',
read: true
}).then(out=>{
console.log('Done generating key pairs');
console.log(out.key)
console.log(out.pubKey)
}).catch(err=>{
console.log('There was a problem : '+err);
});