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

copySync can only copy directories not files #116

Closed
malei0311 opened this issue Mar 6, 2015 · 8 comments
Closed

copySync can only copy directories not files #116

malei0311 opened this issue Mar 6, 2015 · 8 comments

Comments

@malei0311
Copy link

I'm using node(v0.12.0)

@jprichardson
Copy link
Owner

Thanks for the report. I'll look into this next week (unless a PR is submitted before then).

@jprichardson
Copy link
Owner

Do you have code to reproduce this? Which OS? I only ask because of https://github.com/jprichardson/node-fs-extra/blob/master/test/copy-sync.test.js#L29

@malei0311
Copy link
Author

  • os centos 6.2
  • node version v0.12.0

code

if I didn't pass a callback parameter, it worked, as #115

fs.copySync(sourceDir, destDir)

but, it didn't worked below

fs.copySync(sourceDir, destDir, function(err){
})

fs.copy works fine

@jprichardson
Copy link
Owner

You don't pass a callback to the sync methods since they happen immediately and block the process. I think I'll update the documentation to make this clear.

@malei0311
Copy link
Author

thx~, but how can I know if error occur

@awaldow
Copy link

awaldow commented Apr 10, 2015

Since at its core copyFileSync is using the normal node fs.(read|write)Sync methods you would deal with errors in copySync the same as with those, since copySync uses copyFileSync to do the real work anyways. It does a check for existence and explicitly throws an 'EEXISTS' error at the beginning but aside from that any other types of filesystem errors would (I assume) be thrown via the normal fs sync methods, which you should handle with try/catch.

@jprichardson jprichardson modified the milestone: 1.0 Jul 2, 2015
@coryallegory
Copy link

I was snagged by the same issue, the documentation isn't clear on copySync's method signature, or maybe I misread it :S

Either way, it may be convenient to insert the try/catch into the library call to allow for copySync(src, dest, err) or something like that.

@jprichardson
Copy link
Owner

Documented copySync(). Thanks everyone.

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

No branches or pull requests

4 participants