mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
27 lines
629 B
JavaScript
27 lines
629 B
JavaScript
// @ts-check
|
|
|
|
"use strict";
|
|
|
|
const fs = require("node:fs").promises;
|
|
|
|
const [ command, ...args ] = process.argv.slice(2);
|
|
|
|
// eslint-disable-next-line unicorn/prefer-top-level-await
|
|
(async() => {
|
|
if (command === "copy") {
|
|
const [ src, dest ] = args;
|
|
await fs.copyFile(src, dest);
|
|
} else if (command === "delete") {
|
|
const { globby } = await import("globby");
|
|
await Promise.all(
|
|
args.flatMap(
|
|
(glob) => globby(glob)
|
|
.then(
|
|
(files) => files.map((file) => fs.unlink(file))
|
|
)
|
|
)
|
|
);
|
|
} else {
|
|
throw new Error(`Unsupported command: ${command}`);
|
|
}
|
|
})();
|