Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions recipes/dirent-path-to-parent-path/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# `dirent.path` DEP0178

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

See [DEP0178](https://nodejs.org/api/deprecations.html#DEP0178).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This codemod handle:
- `node:fs` and `node:fs/promise` import
- `for` loop
- array methods

it's just the idea I'm not good writer

Copy link
Member Author

@brunocroh brunocroh Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I’m not sure if it makes sense to talk about for or array methods here, it might cause more confusion than clarity in the end,

what nodejs docs say about it:
Screenshot 2025-10-28 at 18 33 44

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by "this codemod handle" I mean "which" case is handled

## Example

**Before:**

```js
const { readdir } = require('node:fs/promises');

const entries = await readdir('/some/path', { withFileTypes: true });
for (const dirent of entries) {
console.log(dirent.path);
}
```

**After:**

```js
const { readdir } = require('node:fs/promises');

const entries = await readdir('/some/path', { withFileTypes: true });
for (const dirent of entries) {
console.log(dirent.parentPath);
}
```

**Before:**

```js
import { opendir } from 'node:fs/promises';

const dir = await opendir('./');
for await (const dirent of dir) {
console.log(`Found ${dirent.name} in ${dirent.path}`);
}
```

**After:**

```js
import { opendir } from 'node:fs/promises';

const dir = await opendir('./');
for await (const dirent of dir) {
console.log(`Found ${dirent.name} in ${dirent.parentPath}`);
}
```
21 changes: 21 additions & 0 deletions recipes/dirent-path-to-parent-path/codemod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
schema_version: "1.0"
name: "@nodejs/dirent-path-to-parent-path"
version: 1.0.0
description: Handle DEP0178 via transforming `dirent.path` to `dirent.parentPath`.
author: Bruno Rodrigues
license: MIT
workflow: workflow.yaml
category: migration

targets:
languages:
- javascript
- typescript

keywords:
- transformation
- migration

registry:
access: public
visibility: public
25 changes: 25 additions & 0 deletions recipes/dirent-path-to-parent-path/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@nodejs/dirent-path-to-parent-path",
"version": "1.0.0",
"description": "Handle DEP0178 via transforming `dirent.path` to `dirent.parentPath`",
"type": "module",
"scripts": {
"test": "npx codemod jssg test -l typescript ./src/workflow.ts ./",
"testu": "npx codemod jssg test -l typescript -u ./src/workflow.ts ./"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nodejs/userland-migrations.git",
"directory": "recipes/dirent-path-to-parent-path",
"bugs": "https://github.com/nodejs/userland-migrations/issues"
},
"author": "Bruno Rodrigues",
"license": "MIT",
"homepage": "https://github.com/nodejs/userland-migrations/blob/main/recipes/dirent-path-to-parent-path/README.md",
"devDependencies": {
"@codemod.com/jssg-types": "^1.0.9"
},
"dependencies": {
"@nodejs/codemod-utils": "*"
}
}
Loading
Loading