#!/usr/bin/env node
import {
fixCjsDts,
fixCjsExports
} from "./chunk-4QUQJTWZ.mjs";
// src/cli.ts
import path from "path";
import { cac } from "cac";
// package.json
var name = "fix-tsup-cjs";
var version = "1.2.0";
// src/to-array.ts
var toArray = (val) => {
if (!val)
return [];
return Array.isArray(val) ? val : [val];
};
// src/cli.ts
var cli = cac(name);
cli.version(version);
cli.command("[...files]", "Custom matching files glob").option("--cwd [path]", "Set fix directory", { default: "dist" }).option("--dts", "Fix commonjs d.ts and d.cts files", { default: true }).option("-i, --ignore [...files]", "Ignore files").option("--silent", "Suppress logs").action(async (files, options) => {
const { dts, silent } = options;
const hasCustomMatchFiles = !!files?.length;
const currentDir = process.cwd();
const cwd = path.resolve(currentDir, options.cwd);
const ignore = toArray(options.ignore);
await fixCjsExports({
files,
globOptions: {
cwd: hasCustomMatchFiles ? currentDir : cwd,
ignore
},
silent
});
if (dts) {
await fixCjsDts({
globOptions: {
cwd,
ignore
},
silent
});
}
});
cli.help();
cli.parse();