-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
Open
brunocroh
wants to merge
9
commits into
nodejs:main
Choose a base branch
from
brunocroh:feat/dirent-path-dep0178
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0b93c74
feat(dirent-path): introduce
brunocroh cbaf511
chore: switch case syntax
brunocroh 748d63e
Merge remote-tracking branch 'upstream/main' into feat/dirent-path-de…
brunocroh 83b53f2
fix: code review feedback
brunocroh ba3f595
fix: variable_declarator handler
brunocroh f5939bd
refactor: turn getScope into a util
brunocroh a59f04c
add support to dynamic import
brunocroh 3d39f27
fix readme.md title
brunocroh cfe98ee
Update recipes/dirent-path-to-parent-path/README.md
brunocroh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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). | ||
|
|
||
| ## 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}`); | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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": "*" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's just the idea I'm not good writer
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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:

There was a problem hiding this comment.
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