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

Refactor + chore cleanup #322

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

Conversation

lukekarrys
Copy link

@lukekarrys lukekarrys commented Oct 10, 2024

Includes commits from #319 and #320 so I could benchmark this more easily.

I've spent some time experimenting with ways to fix #303 and ended up with a pile of refactor/chore commits that I think are useful in general.

The goal of this PR is to not make any behavior changes or regress performance, and also to allow for an easier and more comprehensive fix to #303.

I did benchmark this PR on my machine and it stayed mostly the same with a few % speedup in some rimraf functions:

┌───────────────┬─────────┬─────────┬────────┬─────────┬─────────┬──────────┬────────┐
│ (index)       │ mean    │ median  │ stddev │ max     │ min     │ old mean │ % +/-  │
├───────────────┼─────────┼─────────┼────────┼─────────┼─────────┼──────────┼────────┤
│ posix async   │ 201.196 │ 201.276 │ 1.878  │ 204.2   │ 198.804 │ 211.071  │ -4.679 │
│ native async  │ 228.463 │ 225.544 │ 7.406  │ 241.97  │ 221.517 │ 235.502  │ -2.989 │
│ windows async │ 249.553 │ 240.673 │ 19.318 │ 285.128 │ 229.819 │ 265.057  │ -5.849 │
│ posix sync    │ 307.653 │ 309.176 │ 15.2   │ 327.821 │ 284.9   │ 296.224  │ 3.858  │
│ native sync   │ 332.631 │ 332.498 │ 23.918 │ 365.948 │ 295.841 │ 333.156  │ -0.158 │
│ windows sync  │ 374.274 │ 369.519 │ 24.827 │ 423.804 │ 348.213 │ 374.088  │ 0.05   │
└───────────────┴─────────┴─────────┴────────┴─────────┴─────────┴──────────┴────────┘

Here's a high level overview of the changes:

  • Reconfigure the coverage-map and remove old libtap settings
  • Use t.intercept across all the tests to remove the need for test only environs in the source
  • Add linting with eslint and typescript-eslint
  • Refactor rimraf functions to all use the same ignoreENOENT and fixEPERM functions

@lukekarrys lukekarrys changed the title Lk/refactor Refactor + chore cleanup Oct 10, 2024
This removes the need for checking test only environs in the bin script.
This removes the need for a separate platform.js file and test environ.
This refactors the `src/rimraf-*` files to use `fixEPERM` and `ignoreENOENT` everywhere possible. The biggest churn here is updating the test files to correctly mock the necessary FS functions that are now spread across multiple files.
const [major = 0, minor = 0] = process.version
.replace(/^v/, '')
.split('.')
.map(v => parseInt(v, 10))
Copy link
Author

Choose a reason for hiding this comment

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

@isaacs is it worth removing this version check is use-native now that v14.14.0 is no longer supported by engines?

if (isNaN(v)) {
throw new Error('wat?', { cause: { list, v } })
}
return sqrt(variance(list))
Copy link

Choose a reason for hiding this comment

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

Suggested change
return sqrt(variance(list))
return sqrt(v)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

transient EPERM errors on Windows
2 participants