* 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
This commit is contained in:
Charles Kerr 2018-09-12 12:44:00 -05:00 коммит произвёл GitHub
Родитель 1682170d3d
Коммит 4b5cb7c548
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 10 добавлений и 9 удалений

Просмотреть файл

@ -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 = []