davglass / cpr

Nodejs cp -R
Other
79 stars 80 forks source link

Change behavior of single file copy to imitate cp -R #29

Closed ldanet closed 8 years ago

ldanet commented 8 years ago

When running cp -R in command line on a single file, the source file gets copied at the target path, the last bit of the path becoming the new file name unless there is a trailing /.

For example, starting with this structure:

foo/
 `-- bar.jpg
baz/

cp -R foo/bar.jpg baz/qux.jpg results in:

foo/
 `-- bar.jpg
baz/
 `-- qux.jpg

but cp -R foo/bar.jpg baz/qux/ results in:

foo/
 `-- bar.jpg
baz/
 `-- qux/
      `-- bar.jpg

This pull request recreates this behavior and fixes #28.

davglass commented 8 years ago

Thanks, published in cpr@1.1.2