UNPKG

automin

Version:

"Create a minified mirror version of your js, css, html, json files"

40 lines (39 loc) 1.08 kB
"use strict"; /** * * Perform merge or overwrite * * -- Merge * - Keep files from the output folder and make changes only to the files that * - that exists on input folder * * -- Overwrite * - Delete all files from the output folder before starting * * */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = require("fs"); const get_files_1 = __importDefault(require("./get-files")); const mkdirp_1 = __importDefault(require("mkdirp")); exports.default = (parent, callback) => { const folders = []; let count = 0; (0, get_files_1.default)(parent, { filter_folders: (path) => { folders.push(path); return true; } }).forEach((file) => { (0, fs_1.unlinkSync)(file); count += 1; }); (0, fs_1.rm)(parent, { recursive: true, force: true }, callback); mkdirp_1.default.sync(parent); return folders.length + count; };