mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
24 lines
596 B
JavaScript
24 lines
596 B
JavaScript
// @ts-check
|
|
|
|
import fs from "node:fs/promises";
|
|
import { globby } from "globby";
|
|
|
|
const [ command, ...args ] = process.argv.slice(2);
|
|
|
|
if (command === "copy") {
|
|
const [ src, dest ] = args;
|
|
await fs.copyFile(src, dest);
|
|
} else if (command === "delete") {
|
|
await Promise.all(
|
|
args.flatMap(
|
|
(glob) => globby(glob)
|
|
.then(
|
|
(files) => files.map((file) => fs.unlink(file))
|
|
)
|
|
)
|
|
);
|
|
} else if (command === "remove") {
|
|
await Promise.all(args.map((dir) => fs.rm(dir, { "recursive": true })));
|
|
} else {
|
|
throw new Error(`Unsupported command: ${command}`);
|
|
}
|