"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_pipe_1 = __importDefault(require("chalk-pipe"));
const executeCommand_1 = __importDefault(require("./executeCommand"));
const setBranch = ({ appendedArgs = [], cliAnswers, cliOptions, passThroughParams, state, }) => {
    const hasBranchTypes = Boolean(state.answers.branchTypes);
    const branchNameReplace = hasBranchTypes
        ? state.answers.branchTypes + '/' + state.answers.branchName
        : state.answers.branchName;
    const branchName = state.config.branch.format
        .replace(/\{branchName\}/g, branchNameReplace)
        .replace(/\{branchType\}/g, '');
    if (!branchName) {
        throw new Error('No branchName provided.');
    }
    const commandArray = ['git', 'checkout', '-b', branchName];
    const command = commandArray.join(' ');
    if (cliOptions.dryRun) {
        console.log((0, chalk_pipe_1.default)('orange.bold')('⚗️  DRY RUN: TESTING'));
        console.log((0, chalk_pipe_1.default)('orange')('> command:'));
        console.log((0, chalk_pipe_1.default)('white.italic')(command));
        console.log();
    }
    else {
        (0, executeCommand_1.default)(command);
    }
};
exports.default = setBranch;
//# sourceMappingURL=setBranch.js.map