Skip to content

Commit b33e658

Browse files
better doc
1 parent f48cc04 commit b33e658

File tree

2 files changed

+49
-17
lines changed

2 files changed

+49
-17
lines changed
Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,63 @@
1-
# `fs.rmdir` DEP0147
1+
# `repl.builtinModules` DEP0191
22

3-
This recipe provides a guide for migrating from the deprecated `fs.rmdir` and its synchronous and promise-based counterparts to the new `fs.rm` method in Node.js.
3+
This recipe provides a guide for migrating from the deprecated `repl.builtinModules` to the new `module.builtinModules` property in Node.js.
44

5-
See [DEP0147](https://nodejs.org/api/deprecations.html#DEP0147).
5+
See [DEP0191](https://nodejs.org/api/deprecations.html#DEP0191).
66

77
## Examples
88

99
**Before:**
10-
1110
```js
12-
// Using fs.rmdir with the recursive option
13-
fs.rmdir(path, { recursive: true }, callback);
11+
// Using require with namespace import
12+
const repl = require('node:repl');
13+
console.log(repl.builtinModules);
14+
15+
// Using require with destructuring
16+
const { builtinModules } = require('node:repl');
17+
18+
// Using require with mixed destructuring
19+
const { builtinModules, foo } = require('node:repl');
20+
21+
// Using ES6 import with named import
22+
import { builtinModules } from 'node:repl';
23+
24+
// Using ES6 import with mixed named imports
25+
import { builtinModules, foo } from 'node:repl';
1426

15-
// Using fs.rmdirSync with the recursive option
16-
fs.rmdirSync(path, { recursive: true });
27+
// Using ES6 import with default import
28+
import repl from 'node:repl';
29+
console.log(repl.builtinModules);
1730

18-
// Using fs.promises.rmdir with the recursive option
19-
fs.promises.rmdir(path, { recursive: true });
31+
// Using ES6 import with namespace import
32+
import * as repl from 'node:repl';
33+
console.log(repl.builtinModules);
2034
```
2135

2236
**After:**
23-
2437
```js
25-
// Using fs.rm with recursive and force options
26-
fs.rm(path, { recursive: true, force: true }, callback);
38+
// Using require with namespace import
39+
const module = require('node:module');
40+
console.log(module.builtinModules);
41+
42+
// Using require with destructuring
43+
const { builtinModules } = require('node:module');
44+
45+
// Using require with mixed destructuring
46+
const { foo } = require('node:repl');
47+
const { builtinModules } = require('node:module');
48+
49+
// Using ES6 import with named import
50+
import { builtinModules } from 'node:module';
51+
52+
// Using ES6 import with mixed named imports
53+
import { foo } from 'node:repl';
54+
import { builtinModules } from 'node:module';
2755

28-
// Using fs.rmSync with recursive and force options
29-
fs.rmSync(path, { recursive: true, force: true });
56+
// Using ES6 import with default import
57+
import module from 'node:module';
58+
console.log(module.builtinModules);
3059

31-
// Using fs.promises.rm with recursive and force options
32-
fs.promises.rm(path, { recursive: true, force: true });
60+
// Using ES6 import with namespace import
61+
import * as module from 'node:module';
62+
console.log(module.builtinModules);
3363
```

recipes/repl-builtin-modules/src/workflow.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type Js from "@codemod.com/jssg-types/langs/javascript";
77
* Transform function that converts deprecated repl.builtinModules
88
* to module.builtinModules API.
99
*
10+
* See https://nodejs.org/api/deprecations.html#DEP0191
11+
*
1012
* Handles:
1113
* 1. const repl = require('node:repl'); repl.builtinModules → const module = require('node:module'); module.builtinModules
1214
* 2. const { builtinModules } = require('node:repl'); → const { builtinModules } = require('node:module');

0 commit comments

Comments
 (0)