-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
process: chdir with callback implementation #870
Conversation
Add an optional callback argument to the process.chdir function which enables execution of a closure in a directory different than the outer scope. Also improve error messages that can be thrown and make sure existing tests continue to pass.
Sorry for the extraneous open/close. The Contributor guidelines still reference that API changes should be merged into master, and only after review and possibly major/minor version bumps would it be merged into stable/v1.x, which caused some confusion as master has not been updated in some time. With that out of the way, I don't fully expect this to be merged outright. I'm not especially fond of the way I implemented it, and am probably missing something major, as I'm not much of a C++ developer. If this appears to be something the io.js core team would like to be included in the project, I'd be more than happy to clean this up as needed, after review. Thanks for your time. |
This is basically
but implemented in C++, right? As such, it seems pure sugar, best done in an external module, I don't see why it should be in core. Can you make a better case for why this needs to be in io.js, and not a user-land module? Also, the API seems to promise asynchrony (it has a callback), but it is not in fact asynchronous, and could never become parallel either (since current working directory is part of global process state). |
-1. This seems like it would lead to great user confusion. |
-1:
|
@sam-github That is correct, your example is pretty much exactly what I intended. Ruby and Perl have almost the same API, where the more global I tried to find a way to make this work as I intended, and since I know very little about the inner workings of Node/io.js, this is the only thing I was able to cobble together that let the existing tests pass and contain the behavior I intended, even if it's terribly wrong. Yes, I would like it to be an asynchronous operation, with the callback being common to node's API. @cjihrig Can you explain further how this would lead to great user confusion? I don't disagree, but I would like more insight to your statement so I don't make the same mistake multiple times. |
@sam-github As for the argument of this being in core vs an external module, I really have none except for that similar functionality exists in other languages core and standard libraries (Ruby and Perl, as described in my previous comment), and it feels like a lower level API rather than something implemented externally. Additionally, I've had a personal distaste for external libraries opening and altering core libraries, so creating a completely external module to support this behavior felt cluttering, and creating an extension library didn't feel right. I now realize it might make more sense as a new API within the |
@uxp it would confuse people because it is a synchronous function that appears to be asynchronous. It's also confusing because it's a synchronous |
Add an optional callback argument to the process.chdir function which
enables execution of a closure in a directory different than the outer
scope. Also improve error messages that can be thrown and make sure
existing tests continue to pass.