From 78bb3b813e83121e79f4d4ee32826101ce955e47 Mon Sep 17 00:00:00 2001 From: Jonathan Hedstrom Date: Thu, 5 Jan 2017 11:44:55 -0800 Subject: [PATCH] Defer to phpcs.xml file if present. - Fixes #311 --- tasks/quality.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tasks/quality.js b/tasks/quality.js index ccfd2596..e0cc8034 100644 --- a/tasks/quality.js +++ b/tasks/quality.js @@ -190,11 +190,18 @@ module.exports = function(grunt) { grunt.registerTask('validate', 'Validate the quality of custom code.', function(mode) { phpcsConfig = grunt.config.get('phpcs'); var files; + if (phpcsConfig && phpcsConfig.validate) { - files = filesToProcess(phpcsConfig.validate.src); - if (files.length) { - grunt.config.set('phpcs.validate.src', files); + // Defer to phpcs.xml/phpcs.xml.dist if present. + if (grunt.file.exists('./phpcs.xml') || grunt.file.exists('./phpcs.xml.dist')) { + grunt.config.set('phpcs.validate.src', []); validate.push('phpcs:validate'); + } else { + files = filesToProcess(phpcsConfig.validate.src); + if (files.length) { + grunt.config.set('phpcs.validate.src', files); + validate.push('phpcs:validate'); + } } } eslintConfig = grunt.config.get('eslint');