Skip to content

Handle both string and array outputs from npm view in find-release-plan-version#7

Merged
kategengler merged 2 commits intomainfrom
copilot/fix-version-output-inconsistency
Dec 23, 2025
Merged

Handle both string and array outputs from npm view in find-release-plan-version#7
kategengler merged 2 commits intomainfrom
copilot/fix-version-output-inconsistency

Conversation

Copy link
Contributor

Copilot AI commented Dec 23, 2025

npm view returns a string when a semver range matches a single version, but an array when multiple versions match. The existing jq command .[-1] fails on string inputs.

Changes

  • Updated jq expression to handle both types: if type == "array" then .[-1] else . end
  • Returns last element for arrays, the value itself for strings

Example

# Single match returns string
npm view release-plan@^0.17.2 version --json  # "0.17.2"

# Multiple matches return array  
npm view release-plan@^0.17.0 version --json  # ["0.17.0", "0.17.1", "0.17.2"]

# New jq command handles both correctly
jq -r 'if type == "array" then .[-1] else . end'  # → "0.17.2"
Original prompt

This section details on the original issue you should resolve

<issue_title>npm version output is inconsistent, leads to error</issue_title>
<issue_description>
npm view release-plan@^0.17.2 version --json -> "0.17.2"
npm view release-plan@^0.17.0 version --json -> [ "0.17.0", "0.17.1", "0.17.2" ]

if you have the later version specification in your package.json, it works, as it currently expects an array

the former, fails

We need to make find-replease-plan-version handle both ways</issue_description>

<agent_instructions>Fix find-release-plan-version.yml to work whether npm view returns a string with one version or an array of versions</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: kategengler <444218+kategengler@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix find-release-plan-version to handle version output Handle both string and array outputs from npm view in find-release-plan-version Dec 23, 2025
Copilot AI requested a review from kategengler December 23, 2025 21:28
@kategengler kategengler marked this pull request as ready for review December 23, 2025 21:56
@kategengler kategengler merged commit ceabbca into main Dec 23, 2025
@kategengler kategengler deleted the copilot/fix-version-output-inconsistency branch December 23, 2025 21:58
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.

npm version output is inconsistent, leads to error

2 participants