bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
90 lines (68 loc) • 1.85 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
function _defineProperty2() {
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
_defineProperty2 = function () {
return data;
};
return data;
}
function _ramda() {
const data = _interopRequireDefault(require("ramda"));
_ramda = function () {
return data;
};
return data;
}
function _constants() {
const data = require("../constants");
_constants = function () {
return data;
};
return data;
}
class ConfigHelper {
constructor(command) {
(0, _defineProperty2().default)(this, "command", void 0);
this.command = command;
}
setHubDomain(domain = `hub.${_constants().BASE_WEB_DOMAIN}`) {
this.command.setConfig('hub_domain', domain);
}
getGitPath() {
this.command.getConfig(_constants().CFG_GIT_EXECUTABLE_PATH);
}
setGitPath(gitPath = 'git') {
this.command.setConfig(_constants().CFG_GIT_EXECUTABLE_PATH, gitPath);
}
deleteGitPath() {
this.command.delConfig(_constants().CFG_GIT_EXECUTABLE_PATH);
}
restoreGitPath(oldGitPath) {
if (!oldGitPath) {
return this.deleteGitPath();
}
return this.setGitPath(oldGitPath);
}
backupConfigs(names) {
const backupObject = {};
names.forEach(name => {
backupObject[name] = this.command.getConfig(name);
});
return backupObject;
}
restoreConfigs(backupObject) {
_ramda().default.forEachObjIndexed((val, key) => {
if (val === undefined || val.includes('undefined')) {
this.command.delConfig(key);
} else {
this.command.setConfig(key, val);
}
}, backupObject);
}
}
exports.default = ConfigHelper;