Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --concurrency flag #37

Merged
merged 5 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -13,6 +14,7 @@ const cli = meow(`
--rename=<filename> Rename all <source> filenames to <filename>
--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

<source> can contain globs if quoted

Expand Down Expand Up @@ -44,6 +46,10 @@ const cli = meow(`
type: 'boolean',
default: false,
},
concurrency: {
type: 'number',
default: (os.cpus().length > 0 ? os.cpus().length : 1) * 2,
},
},
});

Expand All @@ -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') {
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ $ cpy --help
--rename=<filename> Rename all <source> filenames to <filename>
--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

<source> can contain globs if quoted

Expand Down