Replace fs-extra outputFile and outputJson with mkdir + writeFile
Recipe ID
org.openrewrite.node.migrate.fs-extra.replace-fs-extra-output-fileArtifact@openrewrite/recipes-nodejsReplaces fs-extra's outputFile, outputJson and their sync variants with a recursive mkdir of the parent directory followed by writeFile from node:fs/promises or node:fs. JSON is written the way jsonfile does, as JSON.stringify(data, replacer, spaces) + '\n'. A path that isn't safe to evaluate twice is hoisted into a const first, which needs a statement to sit before, so such a call in expression position is left alone — as are callback-style calls and JSON options a native rewrite can't reproduce (non-literal options, a custom fs, an EOL other than '\n').
Single recipeProprietary
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.node.migrate.fs-extra.replace-fs-extra-output-fileIf the recipe isn’t available locally, install it with:
mod config recipes npm install @openrewrite/recipes-nodejs