mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-25 16:07:37 +00:00
Fix cp to match unix behavior
In unix, if src is a directory and dest doesn't exist, 'cp -r src dest' will copy src/* into dest. Fix cp('-r', 'src', 'dest') to behave the same way.
This commit is contained in:
parent
dc5c59be36
commit
9ce87da61b
@ -140,8 +140,12 @@ function _cp(options, sources, dest) {
|
||||
// Recursive allows the shortcut syntax "sourcedir/" for "sourcedir/*"
|
||||
// (see Github issue #15)
|
||||
sources.forEach(function(src, i) {
|
||||
if (src[src.length - 1] === '/')
|
||||
if (src[src.length - 1] === '/') {
|
||||
sources[i] += '*';
|
||||
// If src is a directory and dest doesn't exist, 'cp -r src dest' should copy src/* into dest
|
||||
} else if (fs.statSync(src).isDirectory() && !exists) {
|
||||
sources[i] += '/*';
|
||||
}
|
||||
});
|
||||
|
||||
// Create dest
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user