Skip to content

Commit

Permalink
Add --concurrency flag (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Mar 11, 2022
1 parent 8329dc9 commit 8726315
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 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';

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
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

0 comments on commit 8726315

Please sign in to comment.