From 87263154372bf93e91b9f77a8ca11c570e755f19 Mon Sep 17 00:00:00 2001 From: Gyubong Date: Fri, 11 Mar 2022 14:15:20 +0900 Subject: [PATCH] Add `--concurrency` flag (#37) --- cli.js | 7 +++++++ readme.md | 1 + 2 files changed, 8 insertions(+) diff --git a/cli.js b/cli.js index 481dda7..cf7375a 100755 --- a/cli.js +++ b/cli.js @@ -1,5 +1,6 @@ #!/usr/bin/env node import process from 'node:process'; +import os from 'node:os'; import meow from 'meow'; import cpy from 'cpy'; @@ -13,6 +14,7 @@ const cli = meow(` --rename= Rename all filenames to --dot Allow patterns to match entries that begin with a period (.) --flat Flatten directory structure. All copied files will be put in the same directory. + --concurrency Number of files being copied concurrently can contain globs if quoted @@ -44,6 +46,10 @@ const cli = meow(` type: 'boolean', default: false, }, + concurrency: { + type: 'number', + default: (os.cpus().length > 0 ? os.cpus().length : 1) * 2, + }, }, }); @@ -55,6 +61,7 @@ const cli = meow(` overwrite: cli.flags.overwrite, dot: cli.flags.dot, flat: cli.flags.flat, + concurrency: cli.flags.concurrency, }); } catch (error) { if (error.name === 'CpyError') { diff --git a/readme.md b/readme.md index 97acc51..856e410 100644 --- a/readme.md +++ b/readme.md @@ -29,6 +29,7 @@ $ cpy --help --rename= Rename all filenames to --dot Allow patterns to match entries that begin with a period (.) --flat Flatten directory structure. All copied files will be put in the same directory. + --concurrency Number of files being copied concurrently can contain globs if quoted