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

Fail for blank target from auto (or engine) version file #693

Merged
merged 2 commits into from
Oct 16, 2021

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented Oct 1, 2021

Pull Request

Problem

Using auto and engine will fallback to current if the found version file does not contain a target version. This could be due to an empty version file, but the more likely situation is a package.json with no engines field. This is a bit surprising and not particularly useful.

There is a technical argument for current if there is an engines field with a node field which is empty, but even then installing the current version of node is not all that useful.

And, like with dependencies, if you don't specify the version (or if you specify "*" as the version), then any version of node will do.

https://docs.npmjs.com/cli/v7/configuring-npm/package-json#engines

Resolves: #692

Solution

Display an error if the target version is missing (blank).

% echo "" >>  .node-version
% n auto
       found : /Users/john/Documents/Sandpits/n/issues/692/.node-version
        read : 

  Error: file found for auto did not contain target version of node

% rm .node-version

% npm init -y
% n engine
       found : /Users/john/Documents/Sandpits/n/issues/692/package.json
        read : 

  Error: did not find supported versions of node in 'engines' field of package.json

ChangeLog

  • changed: display error if version missing in version file for auto and engine (rather than fallback to current)

@shadowspawn shadowspawn changed the title Fail for unspecified auto (or engine) Fail for blank target from auto (or engine) version file Oct 1, 2021
@shadowspawn shadowspawn merged commit d272114 into develop Oct 16, 2021
@shadowspawn shadowspawn deleted the feature/fail-unspecified-auto branch October 16, 2021 02:13
@shadowspawn shadowspawn added pending release Merged into a branch for a future release, but not released yet and removed pending release Merged into a branch for a future release, but not released yet labels Oct 16, 2021
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.

None yet

1 participant