use-multiple-gits
Version:
CLI tool to manage multiple git configurations (user.name, user.email, SSH keys) with easy switching between identities
28 lines • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateScript = void 0;
const fs_1 = require("./fs");
const errors_1 = require("./errors");
const shellScriptGenerator_1 = require("./shellScriptGenerator");
const shellDetector_1 = require("./shellDetector");
const zshrc_1 = require("./zshrc");
const generateScript = async (config) => {
const shell = (0, shellDetector_1.detectShell)();
const scriptContent = (0, shellScriptGenerator_1.generateSwitchScript)(config, shell === 'unknown' ? 'zsh' : shell);
try {
if (shell === 'powershell') {
// For PowerShell, we need to add to profile instead of creating executable script
await (0, zshrc_1.addPowerShellFunction)(config, scriptContent);
return 'PowerShell profile updated';
}
const scriptPath = (0, fs_1.getScriptPath)(config.name);
await (0, fs_1.writeFile)(scriptPath, scriptContent);
await (0, fs_1.makeExecutable)(scriptPath);
return scriptPath;
}
catch (error) {
throw new errors_1.FileSystemError(`Failed to generate script: ${error.message}`, error);
}
};
exports.generateScript = generateScript;
//# sourceMappingURL=scriptGenerator.js.map