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

Log when name error is found #194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Fresheyeball
Copy link

@Fresheyeball Fresheyeball commented Jul 4, 2020

I recently learned that when using a custom .json file for node2nix a missing name is reported as an error. However, if there is also a package.json with no name, we get the old error.

  • package.json // no name
  • node2nix.json // has name and version
node2nix -i node2nix.json

results in

name: this.config.name.replace("@", "_at_").replace("/", "_slash_"), // Escape characters from scoped package names that aren't allowed

This leads me to believe that the config.name undefined error is just not so limited it can be addressed with a single check. This PR adds more logging so that when this error occurs for yet unknown reasons, it's easier to debug.

@svanderburg
Copy link
Owner

Hi, could you perhaps provide me an example, or simplified example that can reproduce the problem you're facing?

Although I could probably do a better job in error prevention/handling, printing a warning message in a conversion method is a somewhat strange place IMO. I much rather do this before the generation phase starts ,e.g. in the very beginning or during the download process.

Btw, about node2nix's requirements for name and version fields: it actually does not matter what name a JSON file has -- the only thing that matters is the data structure that the JSON file declares:

  • If a JSON file defines an object, then node2nix considers it a package.json specification and requires a name and version field.
  • If a JSON file defines an array, then node2nix considers each entry a package that is obtained from a specific kind of source (e.g. NPM registry, Git repo, URL, directory etc.). It basically interprets string elements as the latest version of a package from the NPM registry, whereas an object is interpreted in the same way as a NPM project dependency.

Maybe this can be explained more clearly in the README.md file.

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.

2 participants