markdownlint/scripts/index.js

28 lines
629 B
JavaScript
Raw Normal View History

// @ts-check
"use strict";
const fs = require("node:fs").promises;
const [ command, ...args ] = process.argv.slice(2);
2021-12-27 22:40:44 +00:00
// 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}`);
}
2021-12-27 22:40:44 +00:00
})();