npmci/dist/npmci.ssh.js
2016-06-25 03:19:29 +02:00

26 lines
3.5 KiB
JavaScript

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