Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Add an option to clear the cache #755

@regseb

Description

@regseb

Feature request description

I want to use depcheck in a project. In the tests, I use mock-fs to mock files and test the integration of depcheck. But it's always the first values that are used by depcheck.

There should be an option to clear the cache.

Code snippets (if applicable)

package.json:

{
    "name": "testcase",
    "version": "1.0.0",
    "type": "module",
    "dependencies": {
        "depcheck": "1.4.3",
        "mock-fs": "5.2.0"
    }
}

index.js

import depcheck from "depcheck";
import mock from "mock-fs";

mock({
    "package.json": JSON.stringify({ dependencies: { foo: "1.0.0" } }),
});
console.log(await depcheck(process.cwd(), {}));
mock.restore();

mock({
    "package.json": JSON.stringify({ dependencies: { bar: "1.0.0" } }),
});
console.log(await depcheck(process.cwd(), {}));
mock.restore();

Any extra info

$ npm install

added 130 packages, and audited 131 packages in 46s

13 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
$ node index.js 
{
  dependencies: [ 'foo' ],
  devDependencies: [],
  missing: {},
  using: {},
  invalidFiles: {},
  invalidDirs: {}
}
{
  dependencies: [ 'foo' ],
  devDependencies: [],
  missing: {},
  using: {},
  invalidFiles: {},
  invalidDirs: {}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions