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

fix: error on isError due to changes of output format of npm view #21

Merged
merged 1 commit into from
Sep 2, 2021

Conversation

sotarok
Copy link
Contributor

@sotarok sotarok commented Sep 2, 2021

Overview

The Following error occurred when the specific condition:

% npx can-npm-publish --verbose
`npm view` command's exit code: 0
`npm view` stdoutJSON 0.0.1
`npm view` stderrJSON null
/can-npm-publish/lib/can-npm-publish.js:111
            return json && "error" in json;
                                   ^

TypeError: Cannot use 'in' operator to search for 'error' in 0.0.1
    at isError (/can-npm-publish/lib/can-npm-publish.js:111:36)
    at is404Error (/can-npm-publish/lib/can-npm-publish.js:114:20)
    at ChildProcess.<anonymous> (/can-npm-publish/lib/can-npm-publish.js:148:17)
    at ChildProcess.emit (node:events:394:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Socket.<anonymous> (node:internal/child_process:450:11)
    at Socket.emit (node:events:394:28)
    at Pipe.<anonymous> (node:net:672:12)

Reproduce and conditions

In npm 7, the output format has been changed from array of single version like [ "0.0.1" ] to a single string like "0.0.1" when the package has only one version.

Conditions:

  • The package only one published version
  • npm 7

The response format of npm view PACKAGE_NAME --json

% npm view PACKAGE_NAME versions --json
"0.0.1"

In npm 6, the same command shows following output:

% npm view PACKAGE_NAME versions --json
[
  "0.0.1"
]

@azu azu merged commit 12d1df4 into azu:master Sep 2, 2021
@azu
Copy link
Owner

azu commented Sep 2, 2021

Thanks!

I've released v1.3.6

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

2 participants