jscpd icon indicating copy to clipboard operation
jscpd copied to clipboard

No output given

Open Thaval opened this issue 4 years ago • 5 comments

Describe the bug A clear and concise description of what the bug is. I installed jscpd using

npm i -g jscpd
npm i -g @jscpd/html-reporter
npm i -g @jscpd/badge-reporter

and navigated to my root project folder, running the command jscpd --pattern "src/**/*.ts"

but the output is empty, I only see Detection time:: 0.244ms

I also tried jscpd -k 10 -l 1

which should definitely find something. As a test I have

console.log("i got a line of code");
console.log("i got a line of code");

in my typescript file.

What's the problem here? The idea to detect duplicate code is awesome, if it would work :/

Desktop (please complete the following information):

  • OS: Windows
  • NodeJS Version [12.18.4]
  • jscpd version [3.3.26]

Thaval avatar Aug 26 '21 12:08 Thaval

Encountering the same issue, also using Windows but with Node 14.18.0.

The following commands find nothing:

jscpd --pattern \"src/**/*.js\"
Detection time:: 0.259ms

jscpd "src/**/*.js\"
Detection time:: 0.257ms

The following command does run and find duplicates, however it catches everything and not just JS files as wanted:

jscpd \"src/**\"

Fdawgs avatar Oct 06 '21 09:10 Fdawgs

Hi, Looks like the issue related to fast-glob package, you can use --format option to detect clones in specified language:

jscpd "src/**" --format "javascript,typescript"

kucherenko avatar Oct 07 '21 06:10 kucherenko

Hi, Looks like the issue related to fast-glob package, you can use --format option to detect clones in specified language:

jscpd "src/**" --format "javascript,typescript"

I have the same problem, and the solution you provide can't solve it

gaoming95 avatar Oct 21 '21 13:10 gaoming95

Looks like I made mistake in last my message, use following command for that:

jscpd --format "javascript,typescript" src/ path1/ path2/ 

kucherenko avatar Oct 21 '21 14:10 kucherenko

Looks like I made mistake in last my message, use following command for that:

jscpd --format "javascript,typescript" src/ path1/ path2/ 

Thanks @kucherenko, this solves it!

Fdawgs avatar Dec 16 '21 13:12 Fdawgs

Hi, Looks like the issue related to fast-glob package, you can use --format option to detect clones in specified language:

jscpd "src/**" --format "javascript,typescript"

hi, I encounter the same issue in analysing vue project, also using Windows but with Node 14.18.0.

jscpd --format "javascript,typescript" src/ path1/ path2/    

can't solve it.

liujiali365 avatar Oct 11 '22 08:10 liujiali365

thank you for the report, will investigate

kucherenko avatar Oct 11 '22 17:10 kucherenko

Hi! I have the same problem. Node 14.17.4

In file @jscpd/finder/dist/files.js in function "getFilesToDetect" after patterns.map() I got patterns like [ 'D:\work\project_name\src/**/*' ]

So in FastGlob.sync() function "getWorks" const task will contain patterns: [ 'D:\work\project_name\src//*', '!/snapshots/', '!/node_modules/**' ]

If in files.js I change const currentPath = fs_extra_1.realpathSync(path) to const currentPath = path; it work good for me.

Maybe it will be helpful for you

JulianaKomarytska avatar Oct 19 '22 23:10 JulianaKomarytska

Same problem. @JulianaKomarytska solution fixed it for me

pledominykas avatar Oct 20 '22 08:10 pledominykas

I think I figured out one problem, at least for me. You must supply a directory on the command AND most important, the directory must end with a slash! That is not what the examples on the main doc page are showing, but I happened to notice Andrey's post above and that's how his directory was listed. I tried a million other things before this. At one point I was just trying to use a simple folder called "src" with 2 duplicate files and finally this is what worked: jscpd src/

You do also need to implement Juliana's suggestion! It was hard for me to find that file - make sure you're looking in the folder that starts with the @ symbol. In Windows, using npm I found the file in ~\AppData\Roaming\npm\node_modules\jscpd\node_modules@jscpd\finder\dist. If you're using yarn, then it's in ~\AppData\Local\Yarn\Data\global\node_modules@jscpd\finder\dist.

So maybe for the original poster they should have navigated to the directory above the root folder, then typed the command: jscpd --pattern "src/**/*.ts" root/

dstorfer-cn avatar Oct 21 '22 20:10 dstorfer-cn

What fixed it for me was adding a . at the end:

# Bad
npx jscpd --pattern '**/*.ts'
# Good
npx jscpd --pattern '**/*.ts' .

serg06 avatar Jun 30 '23 01:06 serg06