-
Notifications
You must be signed in to change notification settings - Fork 169
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(use): create package.json
when calling corepack use
on empty dir
#350
Conversation
sources/specUtils.ts
Outdated
try { | ||
file = await fs.promises.open(manifestPath, `r`); | ||
} catch (err) { | ||
if ((err as NodeError)?.code === `ENOENT`) continue; | ||
throw err; | ||
} | ||
|
||
const content = await fs.promises.readFile(manifestPath, `utf8`); | ||
const content = await file.readFile(`utf8`); | ||
await file.close(); |
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.
Can't we just use readFile
and assign {}
to data
wen catching ENOENT
?
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.
Sure, the only anti-pattern is to rely on existsSync
, as its result might be outdated by the time the readFile
calls is processed.
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.
Could you add a test that makes sure the parent package.json
is updated when ran from a sub-folder?
corepack use foo@1
mkdir src
cd src
corepack use foo@2
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.
Couple of nits, but LGTM overall
Co-authored-by: Maël Nison <nison.mael@gmail.com>
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.
LGTM.
NIT: This seems more like a new feature (feat:
) than a bugfix (fix:
).
I chose |
Right, in that case I agree, it's a bugfix 👍 |
Fixes: #347