mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Update dependency: globby to 12.0.2.
This commit is contained in:
parent
05b9e6e43c
commit
11e9a20531
4 changed files with 29 additions and 24 deletions
|
|
@ -2,20 +2,27 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const globby = require("globby");
|
||||
const fs = require("fs").promises;
|
||||
|
||||
const [ command, ...args ] = process.argv.slice(2);
|
||||
|
||||
if (command === "copy") {
|
||||
const [ src, dest ] = args;
|
||||
fs.copyFileSync(src, dest);
|
||||
} else if (command === "delete") {
|
||||
for (const arg of args) {
|
||||
for (const file of globby.sync(arg)) {
|
||||
fs.unlinkSync(file);
|
||||
}
|
||||
// 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") {
|
||||
// eslint-disable-next-line node/no-unsupported-features/es-syntax
|
||||
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}`);
|
||||
}
|
||||
} else {
|
||||
throw new Error(`Unsupported command: ${command}`);
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue