From e93f734b60b93c96216c3a02eaa76ab9f530547e Mon Sep 17 00:00:00 2001 From: Walter Augustine Date: Wed, 16 Oct 2024 00:47:55 -0400 Subject: [PATCH] feat: add (#126) --- docs/modules/README.md | 1 + docs/modules/fs-extra.md | 60 ++++++++++++++++++++++++++++++++++++++++ docs/templates/module.md | 4 +-- manifests/preferred.json | 6 ++++ 4 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 docs/modules/fs-extra.md diff --git a/docs/modules/README.md b/docs/modules/README.md index e891cb8..297bed9 100644 --- a/docs/modules/README.md +++ b/docs/modules/README.md @@ -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) diff --git a/docs/modules/fs-extra.md b/docs/modules/fs-extra.md new file mode 100644 index 0000000..dfd8978 --- /dev/null +++ b/docs/modules/fs-extra.md @@ -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` diff --git a/docs/templates/module.md b/docs/templates/module.md index 4621d5d..ccea83a 100644 --- a/docs/templates/module.md +++ b/docs/templates/module.md @@ -2,9 +2,9 @@ {Optional description} -# Alternatives +## Alternatives -## {Alternative package name} +### {Alternative package name} {Description of alternative package} diff --git a/manifests/preferred.json b/manifests/preferred.json index 808d22d..33203d2 100644 --- a/manifests/preferred.json +++ b/manifests/preferred.json @@ -90,6 +90,12 @@ "docPath": "glob", "category": "preferred" }, + { + "type": "documented", + "moduleName": "fs-extra", + "docPath": "fs-extra", + "category": "preferred" + }, { "type": "documented", "moduleName": "glob",