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

Unexpected cp behaviour with directories #15

Closed
brendandahl opened this issue May 29, 2012 · 4 comments
Closed

Unexpected cp behaviour with directories #15

brendandahl opened this issue May 29, 2012 · 4 comments

Comments

@brendandahl
Copy link

With unix cp you can do

cp -Rf oneDir/ twoDir/

which copies all the files in oneDir into twoDir. When I do:

cp('-Rf', 'oneDir/', '/twoDir/');

nothing gets copied, I have to do

cp('-Rf', 'oneDir/*', '/twoDir/');

from man cp

If source_file designates a directory, cp copies the directory and the entire subtree connected
at that point. If the source_file ends in a /, the contents of the directory are copied rather
than the directory itself.

@arturadib
Copy link
Collaborator

sounds like a bug indeed, will look into this soon, thanks Brendan.

@can3p
Copy link

can3p commented Nov 15, 2012

I still have the problems with cp function. Consider directory structure like this:
root/

  • dir1/
    • lib/
      • main.js

Work directory is root, and I try to copy dir1 to dir2

$ node

require('shelljs/global')
{}
cp('-R', 'dir1/*', 'dir2/')
shell.js: internal error
Error: ENOENT, no such file or directory 'dir2//lib'
at Object.fs.mkdirSync (fs.js:483:18)
at app/node_modules/shelljs/shell.js:306:14
at Array.forEach (native)
at _cp (app/node_modules/shelljs/shell.js:288:11)
at app/node_modules/shelljs/shell.js:1103:23
at repl:1:2
at REPLServer.self.eval (repl.js:111:21)
at Interface. (repl.js:250:12)
at Interface.EventEmitter.emit (events.js:93:17)
at Interface._onLine (readline.js:199:10)

$ node

require('shelljs/global')
{}
cp('-Rf', 'dir1/*', 'dir2/')
shell.js: internal error
Error: ENOENT, no such file or directory 'dir2//lib'
at Object.fs.mkdirSync (fs.js:483:18)
at app/node_modules/shelljs/shell.js:306:14
at Array.forEach (native)
at _cp (app/node_modules/shelljs/shell.js:288:11)
at app/node_modules/shelljs/shell.js:1103:23
at repl:1:2
at REPLServer.self.eval (repl.js:111:21)
at Interface. (repl.js:250:12)
at Interface.EventEmitter.emit (events.js:93:17)
at Interface._onLine (readline.js:199:10)

I'm using node 0.8.12 on Mac OS X 10.7.5, shelljs version is 0.0.8

@arturadib
Copy link
Collaborator

@can3p sorry, I can't reproduce the problem. is it still happening?

@arturadib
Copy link
Collaborator

@can3p if it is, can you please open a separate issue as the error is different from the original one here? thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants