DavidWells / DavidWells/markdown-magic

dry: true still writes files to disk (dry vs dryRun mismatch with comment-block-replacer)

Open Beginner friendly
#126 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
868
Forks
223
PR merge metrics
No merged PRs in 30d

Description

Summary

With markdown-magic@4.8.0, passing dry: true to markdownMagic() does not prevent disk writes. Files are still modified, while the return value reports filesChanged: [] — so a "check"-style invocation silently mutates the files it was auditing.

Root cause

src/index.js derives its dry-run state from opts.dry (used for the return value and logging), but the actual write lives in the comment-block-replacer package, which reads opts.dryRun — a key index.js never sets or forwards. The two halves of the pipeline disagree about which option name means "don't write".

Repro
const { markdownMagic } = require("markdown-magic");

// file.md contains any transform block, e.g. <!-- docs TOC -->...<!-- /docs -->
const result = await markdownMagic(["./file.md"], { dry: true });

console.log(result.filesChanged); // [] — claims nothing changed
// ...but ./file.md has been rewritten on disk

Passing both keys works around it:

await markdownMagic(files, { dry: true, dryRun: true });
Expected

dry: true performs the full transform pipeline in-memory and never touches disk (the per-file results[].isChanged / updatedContents are already populated correctly in that mode once dryRun is also set).

Suggested fix

Forward dry into the replacer's dryRun option (or unify the option name across the packages).

Environment: markdown-magic@4.8.0, comment-block-replacer as resolved by its lockfile, Node 25.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/index.js at the markdownMagic() option handling and compare the dry state used for results and logging with the options passed to comment-block-replacer. Reproduce the issue with a markdown file containing a transform block and dry: true. Done means the transform still produces in-memory results while the file is not written to disk.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.