-
-
Notifications
You must be signed in to change notification settings - Fork 27
Feat/dirent path dep0178 #248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
0b93c74
cbaf511
748d63e
83b53f2
ba3f595
f5939bd
a59f04c
3d39f27
cfe98ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,51 @@ | ||||||||||||||||
| # `util.log` DEP0178 | ||||||||||||||||
|
|
||||||||||||||||
| This recipe transforms the usage of `dirent.path` to use `dirent.parentPath`. | ||||||||||||||||
|
|
||||||||||||||||
| See [DEP0178](https://nodejs.org/api/deprecations.html#DEP0178). | ||||||||||||||||
|
|
||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
it's just the idea I'm not good writer
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: | ||||||||||||||||
brunocroh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||
|
|
||||||||||||||||
| ```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}`); | ||||||||||||||||
| } | ||||||||||||||||
| ``` | ||||||||||||||||
| 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 |
| 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": "*" | ||
| } | ||
| } |

Uh oh!
There was an error while loading. Please reload this page.