我通过grunt构建我的项目。我想在那里添加grunt-jscpd任务。我无法通过咕噜声来运行它。我在放置Gruntfile.js的同一目录中创建了下一个.cpd.yaml文件:
#.cpd.yaml
path:
- src/main/webapp/js/accounts/
languages:
- javascript
exclude:
- "**/node_modules/**"
当我运行下一个commant" jscpd --languages js"从放置Gruntfile.js的目录,jscpd正常工作,我看到结果:
info: Files search time: duration=58ms
info: Scaning 74 files for duplicates...
info: Scaning for duplicates time: duration=1674ms
info: Scaning... done!
info: Start report generation...
info: Found 7 exact clones with 120 duplicated lines in 10 files
...
3.54% (120 lines) duplicated lines out of 3393 total lines of code.
但是当我通过grunt运行它时,jscpd没有检查我的代码(我运行" grunt jscpd"命令)。 结果如下:
Running "jscpd:js" (jscpd) task
[Function: jscpd]
Used config from ../cm-html/.cpd.yaml
Scaning... done!
Found 0 exact clones with 0 duplicated lines in 0 files
100.00% (0 lines) duplicated lines out of 0 total lines of code.
这是我的笨蛋任务:
jscpd: {
js: {
path: '../cm-html',
exclude: ['../cm-html/src/main/webapp/js/lib/**']
}
},
我如何正确地通过grunt运行它?
答案 0 :(得分:0)
您可以将此插件用于grunt - https://github.com/mazerte/grunt-jscpd
grunt.initConfig({
jscpd: {
javascript: {
path: 'lib/js/'
}
}
}