npmci/dist/npmci.ssh.js

26 lines
3.5 KiB
JavaScript
Raw Normal View History

2016-06-23 20:22:03 +00:00
"use strict";
require("typings-global");
var plugins = require("./npmci.plugins");
2016-06-24 00:54:55 +00:00
var sshRegex = /^(.*)\|?(.*)\|?(.*)/;
var sshInstance;
2016-06-23 20:22:03 +00:00
exports.ssh = function () {
2016-06-24 00:54:55 +00:00
sshInstance = new plugins.smartssh.SshInstance();
2016-06-23 20:22:03 +00:00
plugins.smartparam.forEachMinimatch(process.env, "NPMCI_SSHKEY_*", exports.evaluateSshkey);
2016-06-25 00:55:36 +00:00
sshInstance.writeToDisk();
2016-06-23 20:22:03 +00:00
};
2016-06-24 00:54:55 +00:00
exports.evaluateSshkey = function (sshkeyEnvVarArg) {
var resultArray = sshRegex.exec(sshkeyEnvVarArg);
var sshKey = new plugins.smartssh.SshKey();
if (resultArray[1] && resultArray[1] != "undefined")
2016-06-25 01:19:29 +00:00
sshKey.privKeyBase64 = resultArray[1];
2016-06-24 00:54:55 +00:00
var publicKey;
if (resultArray[2] && resultArray[2] != "undefined")
2016-06-25 01:19:29 +00:00
sshKey.pubKeyBase64 = resultArray[2];
2016-06-24 00:54:55 +00:00
var host;
if (resultArray[3] && resultArray[3] != "undefined")
sshKey.host = resultArray[1];
sshInstance.addKey(sshKey);
2016-06-23 20:22:03 +00:00
};
2016-06-25 01:19:29 +00:00
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5wbWNpLnNzaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ3hCLElBQVksT0FBTyxXQUFNLGlCQUFpQixDQUFDLENBQUE7QUFFM0MsSUFBSSxRQUFRLEdBQUcscUJBQXFCLENBQUE7QUFDcEMsSUFBSSxXQUF3QyxDQUFDO0FBRWxDLFdBQUcsR0FBRztJQUNiLFdBQVcsR0FBRyxJQUFJLE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