Skip to content
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

normalize #30

Closed
wants to merge 2 commits into from
Closed

normalize #30

wants to merge 2 commits into from

Conversation

wraithgar
Copy link
Member

@wraithgar wraithgar commented May 9, 2023

Two commits here, one deps and one feat. Please rebase to merge.

  • deps: add new dependency npm-normalize-package-bin@3.0.1
  • feat: add normalize function

This brings in parity with read-package-json-fast, which is a
normalization method intended for parsing package.json files inside of
an existing node_modules.

Tests were copied straight from that package to ensure functionality was
compatible. The only tests that weren't copied were the ones testing
down into the bin normalization. That is delegated to a subdependency so
these tests only ensure that some normalization is happening.
Eventually as we consolidate our package.json reading libs, bin
normalization can live in this package and be tested here.

Finally, the errors that this package was throwing now include the
metadata from the original errors (such as code) instead of making new
errors with no context.

@wraithgar wraithgar requested a review from a team as a code owner May 9, 2023 21:08
@wraithgar wraithgar changed the title gar/fix normalize May 9, 2023
this[_filename] = resolve(path, 'package.json')
this[_manifest] = {}
this[_readFileContent] = ''
this.#path = path
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the read-package-json code will need this

@wraithgar
Copy link
Member Author

Need to come up with a better name than normalize since we will also be "normalizing" it in the read-package-json implementation too.

One is intended for reading from node_modules in a tree, one is intended for reading before publishing.

@wraithgar
Copy link
Member Author

Maybe prepare and normalize are the right method names. prepare would be the read-package-json implementation

This brings in parity with `read-package-json-fast`, which is a
normalization method intended for parsing package.json files inside of
an existing node_modules.

Tests were copied straight from that package to ensure functionality was
compatible.  The only tests that weren't copied were the ones testing
down into the bin normalization. That is delegated to a subdependency so
these tests only ensure that *some* normalization is happening.
Eventually as we consolidate our package.json reading libs, bin
normalization can live in this package and be tested here.

Finally, the errors that this package was throwing now include the
metadata from the original errors (such as code) instead of making new
errors with no context.
@wraithgar
Copy link
Member Author

#32 will be where this lands. One more fix to go.

@wraithgar wraithgar closed this May 12, 2023
@wraithgar wraithgar deleted the gar/fix branch May 12, 2023 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant