-
-
Notifications
You must be signed in to change notification settings - Fork 139
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
fix: recursively search for packer lock file for all 3 packers supported #502
fix: recursively search for packer lock file for all 3 packers supported #502
Conversation
Hi @Dutzu |
and I'm thinking should we reuse the https://github.com/sindresorhus/find-up |
Sorry about that. I thought I could quickly pull it off in the browser editor. FIxed the code now. As for replacing it with find-up.....your call, but for such a small piece of logic, I wouldn't. Sounds like a pad-left type of scenario. |
hey @Dutzu diff --git a/src/utils.ts b/src/utils.ts
index a49442f..f1d59cd 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -47,9 +47,9 @@ const isPathRoot = (p: string) => rootOf(p) === path.resolve(p);
const findUpIO = (names: string[], directory = process.cwd()): IOO.IOOption<string> =>
pipe(path.resolve(directory), (dir) =>
pipe(
- IO.of(names.map((name) => safeFileExistsIO(path.join(dir, name))).some((value) => value())),
- IO.chain((exists: boolean) => {
- if (exists) return IOO.some(dir);
+ IO.sequenceArray(names.map((name) => safeFileExistsIO(path.join(dir, name)))),
+ IO.chain((exist) => {
+ if (exist.some(Boolean)) return IOO.some(dir);
if (isPathRoot(dir)) return IOO.none;
return findUpIO(names, path.dirname(dir));
}) if you are not familiar with functional programming, it's not the best practice to unwrap Monad ( |
Yep, you got it right, unfortunately I haven't done much functional programming. This was my first encounter with fp-ts. I applied your patch and also gave you rights to the fork in case more touch-ups are needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Dutzu approved
🎉 This PR is included in version 1.48.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This is a quick fix for issue #485.
I stumbled upon it by accident but basically I had a yarn.lock file in my home folder, and because the mechanism for recursively finding the lock file of the project runs up the directory chain outside of the scope of the repo, it could happen.
In the issue i described 2 possible solutions i could see, and decided to push this parallel search as an easy way to fix it. It should basically look recursively up the folder tree for either a package-lock, yarn-lock or pnpm-lock file and stop when it finds one of them rather than first looking for a yarn.lock up into infinity and if it can't find one, move on to the next possible packer lock file and so forth...