繁体   English   中英

我如何从grunt运行jscpd

[英]How I can run jscpd from grunt

我通过咕build建立我的项目。 我想在那里添加grunt-jscpd任务。 我无法通过咕unt声运行它。 我在放置Gruntfile.js的同一目录中创建了下一个.cpd.yaml文件:

#.cpd.yaml
path:
  - src/main/webapp/js/accounts/
languages:
  - javascript
exclude:
  - "**/node_modules/**"

当我从放置Gruntfile.js的目录中运行下一个命令“ jscpd --languages 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正确运行它?

您可以将此插件用于grunt- https://github.com/mazerte/grunt-jscpd

grunt.initConfig({
  jscpd: {
    javascript: {
      path: 'lib/js/'
    }
  }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM