"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrepareOutputDirectory = void 0;
const tslib_1 = require("tslib");
const buildProcessor_1 = require("../buildProcessor");
const fs = (0, tslib_1.__importStar)(require("fs"));
class PrepareOutputDirectory {
    constructor(context) {
        this.context = context;
    }
    async runBuildStep() {
        this.context.updateStatus("Preparing output directory...");
        // Check for tokenscript.xml
        if (!fs.existsSync(this.context.workspace + buildProcessor_1.BuildProcessor.SRC_XML_FILE)) {
            throw new Error("Source xml file not found, are you executing this command from a valid TokenScript workspace?");
        }
        const outDir = this.context.workspace + buildProcessor_1.BuildProcessor.OUTPUT_DIR;
        if (fs.existsSync(outDir)) {
            fs.rmSync(outDir, { recursive: true });
        }
        fs.mkdirSync(outDir);
    }
}
exports.PrepareOutputDirectory = PrepareOutputDirectory;
