npmci/dist/npmci.ssh.js

43 lines
3.5 KiB
JavaScript
Raw Normal View History

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