Skip to content

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

Description

@camacho

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions