-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (27 loc) · 827 Bytes
/
index.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
module.exports = {
loadPlugin: function () {
module.exports = Object.assign(module.exports, {
'connection:tunnel:ssh': function (config) {
/**
* Always delay requires, otherwise your plugin will cause trouble
* with db-migrates performance and generates issues to your users.
*/
const tunnel = require('tunnel-ssh');
if (config.privateKeyPath) {
config.privateKey = require('fs').readFileSync(config.privateKeyPath);
}
return new Promise((resolve, reject) => {
tunnel(config, err => {
if (err) {
return reject(err);
}
resolve();
});
});
}
});
delete module.exports.loadPlugin;
},
name: 'tunnel-ssh',
hooks: ['connection:tunnel:ssh']
};