grunt-phpcs
Advanced tools
Comparing version
@@ -28,3 +28,3 @@ /* | ||
application: { | ||
dir: ['php/**'] | ||
src: ['php/**'] | ||
}, | ||
@@ -31,0 +31,0 @@ options: { |
@@ -19,3 +19,3 @@ { | ||
}], | ||
"version": "0.2.3", | ||
"version": "0.3.0", | ||
"main": "Gruntfile.js", | ||
@@ -29,9 +29,9 @@ "engines": { | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "0.6.0", | ||
"grunt": "0.4.1" | ||
"grunt-contrib-jshint": "^0.11.0", | ||
"grunt": "^0.4.5" | ||
}, | ||
"keywords": [ | ||
"gruntplugin", | ||
"phpunit" | ||
"phpcs" | ||
] | ||
} |
@@ -45,4 +45,25 @@ # grunt-phpcs | ||
### Custom callback | ||
Do whatever you want with the output. | ||
```js | ||
function log(err, stdout, stderr, cb) { | ||
console.log(stdout); | ||
cb(); | ||
} | ||
grunt.initConfig({ | ||
phpcs: { | ||
application: { | ||
src: ['application/classes/*.php', 'application/lib/**/*.php'] | ||
}, | ||
options: { | ||
callback: log | ||
} | ||
} | ||
}); | ||
``` | ||
###Target Properties | ||
####dir | ||
####src | ||
Type: `Array` | ||
@@ -49,0 +70,0 @@ |
@@ -52,3 +52,3 @@ /* | ||
*/ | ||
var buildCommand = function(dir) { | ||
var buildCommand = function() { | ||
@@ -122,5 +122,8 @@ var cmd = path.normalize(config.bin); | ||
var dir = runner.data.dir, | ||
attr; | ||
config = runner.options(defaults); | ||
var files = [].concat.apply([], runner.files.map(function(mapping) { return mapping.src })).sort(); | ||
files = files.filter(function(file, position) { return !position || file != files[position - 1] }); | ||
files = '"' + files.join('" "') + '"'; | ||
var attr; | ||
config = runner.options(defaults); | ||
@@ -133,8 +136,13 @@ for (attr in cliOptions) { | ||
cmd = buildCommand(dir) + ' ' + grunt.file.expand(dir).join(' '); | ||
// Merge task options | ||
Object.keys(runner.data).forEach(function(attr) { | ||
config[attr] = runner.data[attr]; | ||
}); | ||
grunt.log.writeln('Starting phpcs (target: ' + runner.target.cyan + ') in ' + dir.join(' ').cyan); | ||
cmd = buildCommand() + ' ' + files; | ||
grunt.log.writeln('Starting phpcs (target: ' + runner.target.cyan + ') in ' + files.cyan); | ||
grunt.verbose.writeln('Exec: ' + cmd); | ||
done = runner.async(); | ||
done = runner.async(); | ||
}; | ||
@@ -153,2 +161,6 @@ | ||
if (typeof config.callback === 'function') { | ||
config.callback.call(this, err, stdout, stderr, done); | ||
} | ||
if (stdout) { | ||
@@ -155,0 +167,0 @@ grunt.log.write(stdout); |
Sorry, the diff of this file is not supported yet
12683
6.74%209
4.5%133
18.75%