Skip to content

Commit

Permalink
Added nodir option to cli.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Edge committed Mar 17, 2016
1 parent 6b7ee08 commit ff76022
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const cli = meow(`
--parents Preserve path structure
--cwd=<dir> Working directory for source files
--rename=<filename> Rename all <source> filenames to <filename>
--nodir Do not match directories, only files
<source> can contain globs if quoted
Expand All @@ -30,6 +31,7 @@ fn(cli.input, cli.input.pop(), {
rename: cli.flags.rename,
parents: cli.flags.parents,
overwrite: cli.flags.overwrite !== false,
nodir: cli.flags.nodir,
nonull: true
}).catch(err => {
if (err.name === 'CpyError') {
Expand Down
10 changes: 10 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ test('keep path structure with flag "--parents"', async t => {
t.is(read(t.context.tmp, 'cwd/hello.js'), read(t.context.tmp, t.context.tmp, 'cwd/hello.js'));
});

test('ignore directories with flag "--nodir"', async t => {
fs.mkdirSync(t.context.tmp);
fs.mkdirSync(path.join(t.context.tmp, 'nodir'));
fs.writeFileSync(path.join(t.context.tmp, 'nodir/hello.js'), 'console.log("hello");');

await execa('./cli.js', [path.join(t.context.tmp, 'nodir/**/*'), path.join(t.context.tmp, 'dest'), '--nodir']);

t.is(read(t.context.tmp, 'nodir/hello.js'), read(t.context.tmp, 'dest/hello.js'));
});

test('rename filenames but not filepaths', async t => {
fs.mkdirSync(t.context.tmp);
fs.mkdirSync(path.join(t.context.tmp, 'dest'));
Expand Down

1 comment on commit ff76022

@chimon2000
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

referencing sindresorhus/cpy#10

Please sign in to comment.