Skip to content

Commit

Permalink
feat: add (es-tooling#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
walter-0 committed Oct 16, 2024
1 parent 70d5dd3 commit e93f734
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ ESLint plugin.
- [`ezspawn`](./process-exec.md)
- [`faker`](./faker.md)
- [`fast-glob`](./glob.md)
- [`fs-extra`](./fs-extra.md)
- [`glob`](./glob.md)
- [`globby`](./glob.md)
- [`ìnvariant`](./invariant.md)
Expand Down
60 changes: 60 additions & 0 deletions docs/modules/fs-extra.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# fs-extra

`fs-extra` adds some file system methods that previously were not included in the native `fs` module and added `Promise` support to the `fs` methods.
Many of the fs-extra modules have since been implemented natively by Node.

[fs-extra](https://github.com/jprichardson/node-fs-extra)

## Alternatives

### `node:fs`

[Node.js File System Module](https://nodejs.org/docs/latest/api/fs.html)

To use the promise-based APIs:

```js
import * as fs from 'node:fs/promises';
```

To use the callback and sync APIs:

```js
import * as fs from 'node:fs/promises';
```

### Equivalent Methods

- `ensureFile` -> `fs.exists` - deprecated since v1
- `ensureFileSync` -> `fs.existsSync`
- `copySync` -> `fs.copyFileSync`
- `mkdirp` -> fs.mkdir`
- `mkdirpSync` -> `fs.mkdirSync`
- `removeSync` -> `fs.rmSync`
- `remove` -> `fs.rm`
- `move` -> `fs.rename`
- `moveSync` -> `fs.renameSync`
- `ensureDirSync` -> `fs.existsSync`
- `pathExistsSync` -> `fs.existsSync`
- `outputFileSync` -> `fs.writeFileSync`

### Methods that need migrating

- `copy`
- `emptyDir`
- `emptyDirSync`
- `ensureDir`
- `ensureLink`
- `ensureLinkSync`
- `ensureSymlink`
- `ensureSymlinkSync`
- `mkdirs`
- `mkdirsSync`
- `outputFile`
- `outputJson`
- `outputJsonSync`
- `pathExists`
- `readJson`
- `readJsonSync`
- `writeJson`
- `writeJsonSync`
4 changes: 2 additions & 2 deletions docs/templates/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

{Optional description}

# Alternatives
## Alternatives

## {Alternative package name}
### {Alternative package name}

{Description of alternative package}

Expand Down
6 changes: 6 additions & 0 deletions manifests/preferred.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@
"docPath": "glob",
"category": "preferred"
},
{
"type": "documented",
"moduleName": "fs-extra",
"docPath": "fs-extra",
"category": "preferred"
},
{
"type": "documented",
"moduleName": "glob",
Expand Down

0 comments on commit e93f734

Please sign in to comment.