Skip to content

Conversation

@jameswiltshire
Copy link
Contributor

Summary

This PR addresses several critical issues and adds quality-of-life improvements to merge-jsonc.

Changes

Bug Fixes

1. Header Detection in Content Change Detection (fix: correct header detection)

  • Problem: When outputting to JSONC/JSON5 files with headers enabled, the tool compared content without headers but wrote content with headers. This caused incorrect "no change" detection when only the header timestamp differed.
  • Impact: Files wouldn't update even when the header timestamp changed, and dry-run previews didn't show headers that would actually be written.
  • Solution: Changed and dry-run preview to use (with header) instead of (without header).
  • Test Updates: Updated one test to explicitly disable headers when testing pure content change detection.

2. Missing Output Directory Creation (feat: create parent directories)

  • Problem: Tool would fail with an error if the output path's parent directory didn't exist.
  • Impact: Users had to manually create directories before running the tool.
  • Solution: Added automatic parent directory creation in using with recursive option.
  • Test Coverage: Added test case verifying nested directory creation works correctly.

Features

3. Improved Status Messages (feat: improve status messages and add --quiet flag)

  • Enhanced Messages:

    • no_inputs: Now explains missing files and suggests --skip-missing
    • up_to_date: Shows count of input files and clarifies timestamp-based skip
    • no_content_change: Clearer explanation that merged content matches existing output
    • wrote: Includes count of merged files
    • wrote_with_backup: Shows file count alongside backup path
  • New --quiet Flag (-q alias):

    • Suppresses all non-error output for scripting use cases
    • Errors still displayed for debugging
    • Useful in CI/CD pipelines and automated workflows
  • Test Coverage: Updated all existing message tests and added 3 new tests for --quiet behavior.

Testing

All tests pass (85 tests):

  • Core functionality: 16 tests
  • CLI integration: 11 tests
  • CLI module: 11 tests (3 new for --quiet)
  • FS safety: 17 tests
  • Features: 4 tests
  • Config: 6 tests
  • Timing/backup: 20 tests

Code coverage maintained at ~88%.

Breaking Changes

None. All changes are backwards compatible:

  • Header behavior unchanged (default still enabled)
  • Existing CLI flags work as before
  • Message format changes are cosmetic improvements

Migration Guide

No migration needed. Users can optionally:

  • Use --quiet in scripts for cleaner output
  • Rely on automatic directory creation instead of pre-creating paths
  • Benefit from more informative status messages automatically

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses critical bugs in header detection and output directory creation, while adding improved status messages and a --quiet flag for better UX and scripting support.

Key Changes

  • Fixed header inclusion in content change detection and dry-run previews to prevent incorrect "no change" detection when headers differ
  • Added automatic parent directory creation for output paths
  • Enhanced status messages with file counts and clearer explanations, plus new --quiet flag for script-friendly output

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/core.ts Fixed content comparison and preview to use finalText (with header) instead of text (without header)
src/fs-safety.ts Added automatic recursive directory creation in atomicWrite before writing output files
src/cli.ts Updated status messages with file counts and clarity improvements; added --quiet flag with -q alias
test/core.test.ts Added header: false to content change test for isolation; added test for nested directory creation
test/cli.test.ts Updated assertion to match new "Skipped" message format
test/cli-module.test.ts Updated message assertions and added 3 comprehensive tests for --quiet flag behavior
test/timing-and-backup.test.ts Updated assertion to match new "Skipped" message format

jameswiltshire and others added 2 commits December 8, 2025 17:55
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

@jameswiltshire jameswiltshire merged commit ef88121 into main Dec 8, 2025
5 checks passed
@jameswiltshire jameswiltshire deleted the feature/improvements branch December 8, 2025 20:30
@github-actions
Copy link

github-actions bot commented Dec 8, 2025

🎉 This PR is included in version 1.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants