mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Pass COPYFILE_FICLONE to fs.copyFile in npm script helper for better file copy performance where possible.
This commit is contained in:
parent
8dbfe965e9
commit
eb8a0a2b7c
1 changed files with 5 additions and 4 deletions
|
|
@ -1,24 +1,25 @@
|
||||||
// @ts-check
|
// @ts-check
|
||||||
|
|
||||||
import fs from "node:fs/promises";
|
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
||||||
|
import { constants, copyFile, rm, unlink } from "node:fs/promises";
|
||||||
import { globby } from "globby";
|
import { globby } from "globby";
|
||||||
|
|
||||||
const [ command, ...args ] = process.argv.slice(2);
|
const [ command, ...args ] = process.argv.slice(2);
|
||||||
|
|
||||||
if (command === "copy") {
|
if (command === "copy") {
|
||||||
const [ src, dest ] = args;
|
const [ src, dest ] = args;
|
||||||
await fs.copyFile(src, dest);
|
await copyFile(src, dest, constants.COPYFILE_FICLONE);
|
||||||
} else if (command === "delete") {
|
} else if (command === "delete") {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
args.flatMap(
|
args.flatMap(
|
||||||
(glob) => globby(glob)
|
(glob) => globby(glob)
|
||||||
.then(
|
.then(
|
||||||
(files) => files.map((file) => fs.unlink(file))
|
(files) => files.map((file) => unlink(file))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else if (command === "remove") {
|
} else if (command === "remove") {
|
||||||
await Promise.all(args.map((dir) => fs.rm(dir, { "recursive": true })));
|
await Promise.all(args.map((dir) => rm(dir, { "recursive": true })));
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unsupported command: ${command}`);
|
throw new Error(`Unsupported command: ${command}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue