← All recipes
Moderne licensed

Replace fs-extra readJson with JSON.parse of readFile

Recipe IDorg.openrewrite.node.migrate.fs-extra.replace-fs-extra-read-jsonArtifact@openrewrite/recipes-nodejs

Replaces fs-extra's readJson/readJSON and readJsonSync/readJSONSync with JSON.parse of readFile from node:fs/promises or readFileSync from node:fs. An awaited call becomes JSON.parse(await readFile(file, 'utf8')), any other promise use readFile(file, 'utf8').then(JSON.parse). An encoding passed as a string or {encoding} is kept. Calls passing throws, reviver, or other options, and callback-style calls, are left alone. Unlike fs-extra, JSON.parse does not strip a leading byte order mark.

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-read-json

If the recipe isn’t available locally, install it with:

mod config recipes npm install @openrewrite/recipes-nodejs