Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: npm/cacache
base: v17.1.2
Choose a base ref
...
head repository: npm/cacache
compare: v17.1.3
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on May 18, 2023

  1. fix: normalize win32 paths to use on glob expressions (#209)

    ## What
    
    While testing `cacache.verify` I found that on Windows the `stats`
    returned by it are not properly reported. Moreover, I found that
    `cacache.verify` fails to delete files if no cache entries refer to
    them.
    
    `cacache.rm.all` also fails to work on Windows: the cache is not cleared
    after calling this function.
    
    ## Why
    
    The root of the problem is the same: `globify` function is not replacing
    to forward-slashes as [`glob` library is expecting to handle Windows
    paths](https://github.com/isaacs/node-glob#windows).
    
    I found that originally `globify` was at `lib/verify.js`, the
    replacement [of the forward-slashes was made
    correctly](https://github.com/npm/cacache/pull/101/files#diff-eeac8636d9b6fc8549cda5929066bc44196ae8b9daac1f414fdd61e2e1340db6R16).
    
    ```javascript
    const globify = pattern => pattern.split('\\').join('/')
    ```
    
    But when created the file `lib/util/glob.js` and moved `globify` there,
    it [was
    changed](https://github.com/npm/cacache/pull/141/files#diff-20cceb346ffab6392d2b141017e1aa137df33c1c3ce59d5ccc765171586919f4R6)
    to
    
    ```javascript
    const globify = pattern => pattern.split('//').join('/')
    ```
    
    which is causing problems when `glob` is used for obtaining stats and
    cleanup in the case of
    [`verify`](https://github.com/npm/cacache/blob/13a4ba3423d8d33b7d718e7200e5d3a5ec720a6d/lib/verify.js#L113)
    and delete the cache with
    [rm.all](https://github.com/npm/cacache/blob/13a4ba3423d8d33b7d718e7200e5d3a5ec720a6d/lib/rm.js#L29)
    
    ## Change details
    
    Replace backslash by forward-slashes if they are present on a path
    before calling `glob`.
    
    Initially I was going to rollback the change to the first implementation
    of `globify`, but I though it would be more explicit to use
    [path.sep](https://nodejs.org/api/path.html#pathsep).
    
    ## Issues reported
    
    [BUG] rm.all doesn't delete anything on Windows #165
    supita committed May 18, 2023
    Configuration menu
    Copy the full SHA
    a0a5e58 View commit details
    Browse the repository at this point in the history
  2. chore: release 17.1.3

    github-actions[bot] authored and wraithgar committed May 18, 2023
    Configuration menu
    Copy the full SHA
    2ae6d2d View commit details
    Browse the repository at this point in the history