npmci/dist/npmci.ssh.js
2016-07-18 16:56:53 +02:00

43 lines
3.5 KiB
JavaScript

"use strict";
require("typings-global");
const plugins = require("./npmci.plugins");
let sshRegex = /^(.*)\|(.*)\|(.*)/;
let sshInstance;
exports.ssh = () => {
let done = plugins.q.defer();
sshInstance = new plugins.smartssh.SshInstance();
plugins.smartparam.forEachMinimatch(process.env, "NPMCI_SSHKEY_*", evaluateSshEnv);
if (!process.env.NPMTS_TEST) {
sshInstance.writeToDisk();
}
else {
plugins.beautylog.log("In test mode, so not storing SSH keys to disk!");
}
;
done.resolve();
return done.promise;
};
let evaluateSshEnv = (sshkeyEnvVarArg) => {
let resultArray = sshRegex.exec(sshkeyEnvVarArg);
let sshKey = new plugins.smartssh.SshKey();
plugins.beautylog.info("Found SSH identity for " + resultArray[1]);
if (notUndefined(resultArray[1])) {
plugins.beautylog.log("---> host defined!");
sshKey.host = resultArray[1];
}
if (notUndefined(resultArray[2])) {
plugins.beautylog.log("---> privKey defined!");
sshKey.privKeyBase64 = resultArray[2];
}
;
if (notUndefined(resultArray[3])) {
"---> pubKey defined!";
sshKey.pubKeyBase64 = resultArray[3];
}
;
sshInstance.addKey(sshKey);
};
let notUndefined = (stringArg) => {
return (stringArg && stringArg != "undefined" && stringArg != "##");
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtY2kuc3NoLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtY2kuc3NoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsTUFBWSxPQUFPLFdBQU0saUJBQWlCLENBQUMsQ0FBQTtBQUUzQyxJQUFJLFFBQVEsR0FBRyxtQkFBbUIsQ0FBQTtBQUNsQyxJQUFJLFdBQXdDLENBQUM7QUFFbEMsV0FBRyxHQUFHO0lBQ2IsSUFBSSxJQUFJLEdBQUcsT0FBT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