Skip to content

jscpd cli auto run when I only use Node API #734

@godlanbo

Description

@godlanbo

Describe the bug
jscpd cli auto run when I only use Node API. Because the product file contains self-running code

To Reproduce

When I tested it with the following code, I found that jscpd always scanned node_modules. This was completely different from my configuration.

After much debugging, I found that jscpd runs once on the file itself, without any args, so it scanned the entire directory.

const { detectClones } = require('jscpd');

(async () => {
  const clones = await detectClones({
    path: ['./src'],
    threshold: 5,
    ignore: ['**/apis/**'],
    blame: true,
  });
  console.log(clones);
})();

This was a disaster of side effects, and I had no way to cleanly integrate the functionality I needed using the Node API exported by jscpd.

Expected behavior
When using the node api, do not have self-running side effects.

Screenshots
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions