-
Notifications
You must be signed in to change notification settings - Fork 13k
Handle empty package.json files #39937
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
Conversation
@@ -2735,9 +2735,7 @@ namespace ts { | |||
|
|||
type PackageJsonRaw = Record<typeof dependencyKeys[number], Record<string, string> | undefined>; | |||
const dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"] as const; | |||
const stringContent = host.readFile(fileName); | |||
if (!stringContent) return undefined; |
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.
This was the problem. Non-empty package.jsons with parse errors were already handled, but empty files were not.
@typescript-bot pack this |
Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at 0b9b321. You can monitor the build here. |
@typescript-bot cherry-pick this to release-4.0 |
Heya @DanielRosenwasser, I've started to run the task to cherry-pick this into |
const result: PackageJsonInfo[] = []; | ||
forEachAncestorDirectory(getDirectoryPath(filePath), function processDirectory(directory): boolean | undefined { | ||
const processDirectory = (directory: Path): boolean | undefined => { |
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.
All the changes in this file are just to eliminate the .bind(this)
which you noticed were any
.
@typescript-bot cherry-pick this to release-4.0 and LKG |
Heya @DanielRosenwasser, I've started to run the task to cherry-pick this into |
Hey @DanielRosenwasser, I've opened #39938 for you. |
Component commits: 0b9b321 Handle empty package.json files
Hey @DanielRosenwasser, I couldn't open a PR with the cherry-pick. (You can check the log here). You may need to squash and pick this PR into release-4.0 manually. |
Component commits: 0b9b321 Handle empty package.json files
Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build. |
Confirmed, no longer crashes for me. |
…39938) * Cherry-pick PR #39937 into release-4.0 Component commits: 0b9b321 Handle empty package.json files * Update LKG Co-authored-by: Andrew Branch <[email protected]> Co-authored-by: typescript-bot <[email protected]>
Fixes #39923
Thanks for investigating @DanielRosenwasser; it was easier for me just to throw this together since I knew where to put a test.