No output given
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]
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/**\"
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, Looks like the issue related to
fast-globpackage, you can use--formatoption 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
Looks like I made mistake in last my message, use following command for that:
jscpd --format "javascript,typescript" src/ path1/ path2/
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!
Hi, Looks like the issue related to
fast-globpackage, you can use--formatoption 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.
thank you for the report, will investigate
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
Same problem. @JulianaKomarytska solution fixed it for me
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/
What fixed it for me was adding a . at the end:
# Bad
npx jscpd --pattern '**/*.ts'
# Good
npx jscpd --pattern '**/*.ts' .