forked from micalevisk/ssh-keygen-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
50 lines (44 loc) · 1.02 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var keygen = require('./src/ssh-keygen');
function runCallbackVersion(onDone) {
console.log('[callback API] Generating key pair');
keygen(
{
comment: '[email protected]',
read: true,
type: 'ed25519',
destroy: true,
},
function (err, out) {
if (err) {
console.log('There was a problem:', err);
process.exitCode = 1;
} else {
console.log('Done generating key pairs');
console.log(out.key);
console.log(out.pubKey);
}
onDone();
},
);
}
async function runPromiseVersion(onDone) {
console.log('[promise API] Generating key pair');
try {
const out = await keygen({
comment: '[email protected]',
read: true,
destroy: true,
});
console.log('Done generating key pairs');
console.log(out.key);
console.log(out.pubKey);
} catch (err) {
console.log('There was a problem:', err);
process.exitCode = 2;
} finally {
onDone();
}
}
runCallbackVersion(() => {
runPromiseVersion(() => {});
});