Registry
Nnodejs avatar

nodejs/dirent-path-to-parent-path

Handle DEP0178 via transforming `dirent.path` to `dirent.parentPath`.

nodejs6,426 executions

  • transformation
  • migration
Connect a repo
npx codemod @nodejs/dirent-path-to-parent-path

dirent.path DEP0178

This codemod transforms the usage of dirent.path to use dirent.parentPath.

See DEP0178.

Example

readdir

diff
  const { readdir } = require('node:fs/promises');
  const entries = await readdir('/some/path', { withFileTypes: true });
  for (const dirent of entries) {
-   console.log(dirent.path);
+   console.log(dirent.parentPath);
  }

opendir

diff
  import { opendir } from 'node:fs/promises';
  const dir = await opendir('./');
  for await (const dirent of dir) {
-   console.log(`Found ${dirent.name} in ${dirent.path}`);
+   console.log(`Found ${dirent.name} in ${dirent.parentPath}`);
  }

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.