Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 2, 2025

Problem

When running semver-cli with post-version hooks, the console output was displaying [object Object] instead of the actual version string:

Invoking post_version hook...
patching [object Object] in ./src/ubiquitous/Ubiquitous.csproj
1.3.3-pre.70+18193237869.5

Expected output:

Invoking post_version hook...
patching 1.3.3-pre.70+18193237869.5 in ./src/ubiquitous/Ubiquitous.csproj
1.3.3-pre.70+18193237869.5

Root Cause

The replace hook in src/hooks/replace.ts was interpolating SemVer objects directly into template literals. When JavaScript converts objects to strings in template literals without explicit formatting, it produces [object Object].

Solution

Fixed the console.log statement in src/hooks/replace.ts to use the format() function (already imported from the semver library) to convert SemVer objects to strings before logging:

// Before
console.log(`replacing ${previous} -> ${current} in ${file}`);

// After
const previousString = format(previous);
const currentString = format(current);
console.log(`replacing ${previousString} -> ${currentString} in ${file}`);

Note: The patch hook was already correctly using format() and did not need changes.

Testing

  • Added comprehensive test coverage for both patch and replace hooks to verify console output formatting
  • All 42 tests pass (40 existing + 2 new test suites)
  • Manually verified the fix with scenarios matching the reported issue
  • Code formatting and linting checks pass

Fixes #[issue-number]

Original prompt

This section details on the original issue you should resolve

<issue_title>Hook output says [object Object]</issue_title>
<issue_description>I ran the hook and it showed me this output:

Invoking post_version hook...
patching [object Object] in ./src/ubiquitous/Ubiquitous.csproj
1.3.3-pre.70+18193237869.5

The [object Object] appears to be console logging a SemVer object that was expected to be a version string. Or maybe its a regex match object, either way it should be formatted as a string properly.

Expected:

patching [1.3.3] in ./src/ubiquitous/Ubiquitous.csproj

Actual

patching [object Object] in ./src/ubiquitous/Ubiquitous.csproj</issue_description>

<agent_instructions>@copilot please verify that the hook output logging is formatting objects correctly. I'm not sure if they are regex match objects or a semver object thats being logged but please make sure that it is printing the version string value.</agent_instructions>

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

Fixes #130

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@Copilot Copilot AI changed the title [WIP] Hook output says [object Object] Fix hook output displaying [object Object] instead of version strings Oct 2, 2025
@Copilot Copilot AI requested a review from justinmchase October 2, 2025 13:28
Copilot finished work on behalf of justinmchase October 2, 2025 13:28
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.

Hook output says [object Object]

3 participants