Skip to content
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

Remove fs-extra #147

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Remove fs-extra #147

wants to merge 3 commits into from

Conversation

jfmengels
Copy link
Owner

Fixes #120

Removes the dependency on fs-extra. As @lydell pointed out, fs.copyFileSync already exists in core fs.
fs.copy (which copies entire directories) however doesn't. I chose to fix this by hardcoding which files to copy (which is faster, though potentially error-prone 🤷)

Now that fs-extra is absent from the dependencies, tsc complains about the files that reference it in the new-package/ folder. Those files are copied over and not included, but do use fs-extra (mostly because of the "need" to copy entire directories, ideally in a sync manner). I don't know how to suppress this error, and if I ignore the file, then ESLint complains that it can't parse it.

If anyone has an idea on how to fix this, I'm all ears!

@jfmengels jfmengels added the help wanted We could use your help label Mar 17, 2024
Copy link

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/fs-extra@9.1.0 filesystem Transitive: environment +5 222 kB ryanzim

🚮 Removed packages: npm/fs-extra@9.0.0

View full report↗︎

@lydell
Copy link
Contributor

lydell commented Mar 17, 2024

You can use fs.cpSync(src, dest, { recursive: true }) to copy whole dirs. https://nodejs.org/api/fs.html#fscpsyncsrc-dest-options

Available since 16.7.0, marked as Experimental, though. I use it in scripts without trouble, but I’m not sure if I’d dare doing it in package code.

const util = require('util');
const fs = require('graceful-fs');
const {rimraf} = require('rimraf');

const copyFile = util.promisify(fs.copyFile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, there’s a a promises API: https://nodejs.org/api/fs.html#promises-api

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I looked for it in my code but didn't see any usages, so I thought they must have appeared after v10.

@jfmengels
Copy link
Owner Author

For now elm-review supports v10 of Node.js and above, although I think that support for v10 and v12 is broken because of indirect dependencies 😞, but supporting older versions including v14 is still the aim.

Maybe I should break this in a future version because for a soon-to-be feature I'll need a more recent version of glob which only supports ">=16 || 14 >=14.17". Maybe that would be a good time to cut a major version of the CLI 🤷

@lydell
Copy link
Contributor

lydell commented Mar 19, 2024

You are correct, Node.js 10 and 12 are currently broken. Given that:

  • Not very many people have complained about it.
  • Node.js 10 and 12 have been EOL for quite some time now.
  • You can release major versions of the CLI without causing problems like with the Elm package (which would make all rule packages incompatible).

… I would say that it could be time to release that major version with some cleanups :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We could use your help
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace fs-extra
2 participants