0
我嘗試爲WordPress實現plugin,我使用phpcs
和WordPress
標準。Grunt phpcs多任務不運行
在我的情況的問題是,默認WordPress
標準phpcs
檢查也爲WordPress的-VIP是出於我的需要,我喜歡做的事情,是測試我的代碼對Extra
,Docs
和Core
標準。
所以,在我的應用我有安裝grunt-phpcs
模塊和內部我Gruntfile.js
我安裝的示例代碼,就像下面和正常工作:
phpcs : {
application : {
src : [
'includes/**/*.php',
'php/**/*.php',
'my-plugin.php'
]
},
options : {
bin : '/usr/local/bin/phpcs',
standard : 'WordPress-Extra'
}
}
但正如我上面描述,這不解決我的問題,所以我嘗試以下方法:
phpcs : {
extra : {
application : {
src : [
'includes/**/*.php',
'php/**/*.php',
'my-plugin.php'
]
},
options : {
bin : '/usr/local/bin/phpcs',
standard : 'WordPress-Extra'
}
},
docs : {
application : {
src : [
'includes/**/*.php',
'php/**/*.php',
'my-plugin.php'
]
},
options : {
bin : '/usr/local/bin/phpcs',
standard : 'WordPress-Docs'
}
},
core : {
application : {
src : [
'includes/**/*.php',
'php/**/*.php',
'my-plugin.php'
]
},
options : {
bin : '/usr/local/bin/phpcs',
standard : 'WordPress-Core'
}
}
}
但是這一次,當我嘗試運行grunt phpcs:extra
或grunt phpcs:docs
或grunt phpcs:core
,我得到的結果是phpcs --help
,這意味着phpcs
不以這種方式工作。
那麼,有沒有其他的方式來執行相同的任務,但這次是工作?
另一種選擇,我想的是做類似如下:
grunt.registerTask('phpcs_extra', function() {
// do stuff
}
grunt.registerTask('phpcs_docs', function() {
// do stuff
}
grunt.registerTask('phpcs_core', function() {
// do stuff
}
,但我不知道是否能正常工作。
謝謝! :) 那太棒了 ... –