"use strict";
/**
 * Script removes all files that matches specified pattern in folder you also provide.
 *
 * Parameters:
 *  --searchDir Directory where script will do search
 *
 *  @type {string}
 *
 *  --pattern RegExp pattern without slashes (/). For example, styles.d.ts$ becomes /styles.d.ts$/
 *
 *  @type {string}
 */
Object.defineProperty(exports, "__esModule", { value: true });
const __1 = require("../..");
const fs = require("fs");
const path = require("path");
const argument_parser_1 = require("@eigenspace/argument-parser");
const argParser = new argument_parser_1.ArgumentParser();
const argv = argParser.get(process.argv.slice(2));
const searchDir = argv.get('searchDir');
const pattern = argv.get('pattern');
if (!searchDir || !pattern) {
    throw new Error('pattern and searchDir properties is required');
}
const regExp = new RegExp(pattern);
__1.walkThrough(searchDir, (dir, file) => {
    const concatenatedPath = path.join(dir, file);
    if (fs.statSync(concatenatedPath).isFile() && regExp.test(file.toString())) {
        fs.unlinkSync(concatenatedPath);
        // eslint-disable-next-line no-console
        console.log('removed file:', file);
    }
});
//# sourceMappingURL=remove-files-by-pattern.js.map