Comments (8)
Strange, I received an email response to this, but it's not showing here.
Hm, under Node 0.11 I get an array with one Error ([Error]) and under Node 0.10 I get only Error. Possible bug? It happens when I try to create a file under another one (e.g. LICENSE/file) when license is a markdown file from github repo.
Yeah that's super strange. It should definitely always return either one or the other. My recollection was that the code would always return an array of errors, but I don't have it in front of me now.
from ncp.
Yep, because I've noticed that it's not related to that library. fs-extra
does the same (might be Node related problem).
from ncp.
I've been seeing effects of this for months, and i had no idea what was going on. Since I was ignoring errors anyway, I didn't spend the time to look into it, but from time to time I added some extra info to my script to help me look into it whenever it popped up again.
I finally figured out this was coming from ncp
. It is super terrible to have your callback receive errors in two different ways depending on your configuratin. Its also terrible (but less super) to call the callback with an error array (as stated by the OP). This is not the node way, and this module shouldn't be doing it. There isn't even any reason to do it that way: if you have stoponerr
off, the callback will be called multiple times anyway - why not just call it with each error individually?
Also, if you pass one in, there is absolutely no reason to call the error stream with an array of errors.
Please fix the interface so that only single errors are passed to the callback and error stream. Or if you're too lazy, please make it super clear in the docs that this is how things work.
from ncp.
+1 @fresheneesz . Actually, on Heroku, I am getting single objects and on Mac, I receive an array. My simple fix is to basically do err = err[0] || err
to make it super clear, but actually, it's quite hard to write unit tests for my method using that library as depending on configuration, I receive different error messages for exactly the same thing!
from ncp.
Three years ago, that array thing seemed like a great idea. It's definitely not worth the trouble, though, so I'm going to drop it.
I plan to review a bunch of PRs today, with an eye on releasing a 1.0
version. I'll include this change in that.
from ncp.
Thanks @AvianFlu, I am developing a library where your package is quite important dependency. I'd love to see a fixed version, have you got an idea why I may receive different errors depending on OS I am? I suppose it's due to different OS implementations of filesystem operations.
If you need any help - you can count me in (especially in terms of bugs)
from ncp.
Thanks Avian!
from ncp.
This one is bit old :D but I'm using version 2.0.0
, and I still see an array, is it now on purpose or you guys forgot to change this?
from ncp.
Related Issues (20)
- Filter not working as expected HOT 1
- There is no `--dereference` option
- error in useage for options
- EEXIST: file already exists, mkdir
- Callback is triggered even if not finished HOT 2
- Can`t copy simlink on mounted windows samba shares.
- Filter is not working HOT 4
- callback not called HOT 2
- Add options for copy HOT 1
- Copy files recursively to the destination in Windows creating unwanted folders HOT 12
- How to apply filter on files only?
- silence mode
- Audit vulnerabilities detected in the ncp project on Tag: v2.0.0
- Race condition when 2 calls copying files to the same nonexistent directory
- Race condition when 2 calls copying files to the same directory
- Callback is called before file is copied
- Race condition when 2 calls copying files to the same path
- Another race condition when 2 calls copying files to the same path
- Add vars
- Filter does not work in CLI
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ncp.