From 4b5cb7c5489580dd568a653fb2d382bdd72568a2 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 12 Sep 2018 12:44:00 -0500 Subject: [PATCH] fix: cpplint didn't work in GN (#14581) * fix: cpplint didn't work in GN * feat: make cpplint non-errors less noisy * refactor: remove unneeded findCppLint helper We don't need this in the GN world: it's the user's responsibility to have depot_tools in their path. * refactor: use const instead of let where possible --- script/cpplint.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/script/cpplint.js b/script/cpplint.js index 813b2455b0d..47aa4f90558 100755 --- a/script/cpplint.js +++ b/script/cpplint.js @@ -2,18 +2,24 @@ const { GitProcess } = require('dugite') const childProcess = require('child_process') -const fs = require('fs') const klaw = require('klaw') const minimist = require('minimist') const path = require('path') const SOURCE_ROOT = path.normalize(path.dirname(__dirname)) -const LINTER_PATH = path.join(SOURCE_ROOT, 'vendor', 'depot_tools', 'cpplint.py') function callCpplint (filenames, args) { - if (args.verbose) console.log([LINTER_PATH, ...filenames].join(' ')) + const linter = 'cpplint.py' + if (args.verbose) console.log([linter, ...filenames].join(' ')) try { - console.log(String(childProcess.execFileSync(LINTER_PATH, filenames, {cwd: SOURCE_ROOT}))) + childProcess.execFile(linter, filenames, {cwd: SOURCE_ROOT}, (error, stdout, stderr) => { + if (error) { + console.warn(error) + } + for (const line of stderr.split(/[\r\n]+/)) { + if (!line.startsWith('Done processing ')) console.warn(line) + } + }) } catch (e) { process.exit(1) } @@ -87,11 +93,6 @@ const blacklist = new Set([ ].map(tokens => path.join(SOURCE_ROOT, ...tokens))) async function main () { - if (!fs.existsSync(LINTER_PATH)) { - console.log('[INFO] Skipping cpplint, dependencies have not been bootstrapped') - return - } - const args = parseCommandLine() let filenames = []