@reliverse/rse
Version:
@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power
14 lines (13 loc) • 631 B
JavaScript
import path from "@reliverse/pathkit";
import fs from "@reliverse/relifso";
import { relinka } from "@reliverse/relinka";
import { glob } from "tinyglobby";
export async function removeComments(cwd) {
const files = await glob("**/*.{js,jsx,ts,tsx}", { cwd });
for (const file of files) {
const content = await fs.readFile(path.join(cwd, file), "utf-8");
const withoutComments = content.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*/g, "").replace(/^\s*[\r\n]/gm, "");
await fs.writeFile(path.join(cwd, file), withoutComments);
}
relinka("success", "Removed comments from all TypeScript/JavaScript files");
}