-
Notifications
You must be signed in to change notification settings - Fork 775
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
Comments
Thanks for the report. I'll look into this next week (unless a PR is submitted before then). |
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 |
codeif 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){
})
|
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. |
thx~, but how can I know if error occur |
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. |
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. |
Documented |
I'm using node(v0.12.0)
The text was updated successfully, but these errors were encountered: