dbl-utils
Version:
Utilities for dbl, adba and others projects
72 lines (71 loc) • 2.7 kB
JavaScript
#! bin/ts-node
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path = __importStar(require("path"));
const purge_css_1 = __importDefault(require("./purge-css")); // Importa la función desde otro archivo
const yargs_1 = __importDefault(require("yargs"));
const helpers_1 = require("yargs/helpers");
const args = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
.option("css", {
type: "string",
describe: "Path to the CSS file generated by the build",
demandOption: true,
})
.option("html", {
type: "string",
describe: "Path to the HTML file used for purging",
demandOption: true,
})
.help()
.alias("help", "h").argv;
// Infer output CSS file path by replacing .html with .css
console.log("css", args.css);
console.log("html", args.html);
const cssFilePath = path.resolve(args.css);
const htmlFilePath = path.resolve(args.html);
const outputCssFilePath = htmlFilePath.replace(/\.html$/, ".css");
(0, purge_css_1.default)(cssFilePath, htmlFilePath, outputCssFilePath)
.then(() => {
console.log("DONE");
process.exit();
})
.catch((err) => {
console.error("ERROR:", err.message);
process.exit(1);
});