Skip to content

Commit c6761e3

Browse files
Update v22-to-v24.mdx
1 parent 6e7e30a commit c6761e3

File tree

1 file changed

+5
-55
lines changed

1 file changed

+5
-55
lines changed

apps/site/pages/en/blog/migrations/v22-to-v24.mdx

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ You can find this codemod in the [Codemod Registry](https://app.codemod.com/regi
8181
npx codemod run @nodejs/crypto-rsa-pss-update
8282
```
8383

84-
#### Example:
84+
#### Example
8585

8686
```js displayName="Before"
8787
const crypto = require('node:crypto');
@@ -181,7 +181,7 @@ You can find this codemod in the [Codemod Registry](https://app.codemod.com/regi
181181
npx codemod run @nodejs/fs-access-mode-constants
182182
```
183183

184-
#### Example:
184+
#### Example
185185

186186
```js displayName="Before"
187187
const fs = require('node:fs');
@@ -209,7 +209,7 @@ You can find this codemod in the [Codemod Registry](https://app.codemod.com/regi
209209
npx codemod run @nodejs/fs-truncate-fd-deprecation
210210
```
211211

212-
#### Example:
212+
#### Example
213213

214214
```js displayName="Before"
215215
const { truncate, open, close } = require('node:fs');
@@ -247,7 +247,7 @@ You can find this codemod in the [Codemod Registry](https://app.codemod.com/regi
247247
npx codemod run @nodejs/process-assert-to-node-assert
248248
```
249249

250-
## Example
250+
#### Example
251251

252252
```js displayName="Before"
253253
process.assert(condition, 'Assertion failed');
@@ -258,56 +258,6 @@ import assert from 'node:assert';
258258
assert(condition, 'Assertion failed');
259259
```
260260

261-
## Additional Notes
261+
#### Additional Notes
262262

263263
This codemod use [`fs` capability](https://docs.codemod.com/jssg/security) to read the `package.json` file and determine if the project is using ES modules or CommonJS. Based on this information, it adds the appropriate import statement for the `assert` module.
264-
265-
#### `dirent-path-to-parent-path`
266-
267-
This codemod transforms the usage of `dirent.path` to use `dirent.parentPath`.
268-
269-
See [DEP0178](https://nodejs.org/api/deprecations.html#DEP0178).
270-
271-
You can find this codemod in the [Codemod Registry](https://app.codemod.com/registry/@nodejs/dirent-path-to-parent-path).
272-
273-
```bash
274-
npx codemod run @nodejs/dirent-path-to-parent-path
275-
```
276-
277-
#### Examples
278-
279-
##### readdir
280-
281-
```js displayName="Before"
282-
const { readdir } = require('node:fs/promises');
283-
const entries = await readdir('/some/path', { withFileTypes: true });
284-
for (const dirent of entries) {
285-
console.log(dirent.path);
286-
}
287-
```
288-
289-
```js displayName="After"
290-
const { readdir } = require('node:fs/promises');
291-
const entries = await readdir('/some/path', { withFileTypes: true });
292-
for (const dirent of entries) {
293-
console.log(dirent.parentPath);
294-
}
295-
```
296-
297-
##### opendir
298-
299-
```js displayName="Before"
300-
import { opendir } from 'node:fs/promises';
301-
const dir = await opendir('./');
302-
for await (const dirent of dir) {
303-
console.log(`Found ${dirent.name} in ${dirent.path}`);
304-
}
305-
```
306-
307-
```js displayName="After"
308-
import { opendir } from 'node:fs/promises';
309-
const dir = await opendir('./');
310-
for await (const dirent of dir) {
311-
console.log(`Found ${dirent.name} in ${dirent.parentPath}`);
312-
}
313-
```

0 commit comments

Comments
 (0)