-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Misleading documentation #876
Comments
@antongolub please take a look, thanks. |
I see... |
@antongolub is there another API we could use to replace the context hook? seems like node upstream wants to remove it in its current capacity - maybe it should be reimplemented |
@gear4s, it looks as though it is going to be. Thanks for highlighting this. We'll keep that in mind. @antonmedv, fyi. https://nodejs.org/api/async_hooks.html#async-hooks
|
Could you tell us more about your practical example? Why do you need to switch the process dir in your case? Why not just |
I am building a tool to perform migrations of folders and files, and each migration has steps to execute. each step is executed in a effectively I am trying to do this within(async () => {
cd(`${basePath}/project/folder`);
await $`sed -i '' 's|../path|../path2|' ./utils.js`;
await $`sed -i '' 's|${__dirname}/../../|${__dirname}/../|' ./utils.js`;
await $`sed -i '' 's|project/tests|tests|' ./folder/generator.sh`;
});
within(async () => {
cd(basePath); // << failure happens here
await fs.move(`./folder/folder`, `./otherFolder`);
await fs.move(`./folder/folder2`, `./otherFolder2`);
}); |
So do we need to update some docs? |
We have a notice: https://google.github.io/zx/api#cd Should additional description be provided? |
Let's add more documentation to https://google.github.io/zx/api#syncprocesscwd More examples and explain what is the difference in terms of async contexts. For example, without syncprocesscwd a different callback maybe out of sync. |
after doing some research into async hooks, do you guys think there could be another method of tracking cd in separate within contexts? using something like https://github.com/laverdet/isolated-vm or https://github.com/avoidwork/tiny-worker |
Tiny-worker just spawns a process with different node script. This will not help here. Isolates are cool. Bur also not applicable here. |
Expected Behavior
The documentation for within() does not use
cd()
due to it touchingprocess.cwd
and not reverting in some way, but having no mention of this side-effect as part ofwithin()
Actual Behavior
The documentation for within() uses
cd()
which changes theprocess.cwd
of the entire script and introduces parity betweenprocess.cwd
and$`cd`
Steps to Reproduce
Specifications
The text was updated successfully, but these errors were encountered: