Skip to content

Commit

Permalink
build: fix invocation of cpplint on Windows (#26040)
Browse files Browse the repository at this point in the history
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
  • Loading branch information
trop[bot] and dsanders11 committed Oct 19, 2020
1 parent 62536dc commit fd3ce5f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions script/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ const BLACKLIST = new Set([
['spec', 'ts-smoke', 'runner.js']
].map(tokens => path.join(SOURCE_ROOT, ...tokens)));

const IS_WINDOWS = process.platform === 'win32';

function spawnAndCheckExitCode (cmd, args, opts) {
opts = Object.assign({ stdio: 'inherit' }, opts);
const status = childProcess.spawnSync(cmd, args, opts).status;
if (status) process.exit(status);
}

function cpplint (args) {
const result = childProcess.spawnSync('cpplint.py', args, { encoding: 'utf8' });
const result = childProcess.spawnSync(IS_WINDOWS ? 'cpplint.bat' : 'cpplint.py', args, { encoding: 'utf8', shell: true });
// cpplint.py writes EVERYTHING to stderr, including status messages
if (result.stderr) {
for (const line of result.stderr.split(/[\r\n]+/)) {
Expand All @@ -39,8 +41,9 @@ function cpplint (args) {
}
}
}
if (result.status) {
process.exit(result.status);
if (result.status !== 0) {
if (result.error) console.error(result.error);
process.exit(result.status || 1);
}
}

Expand Down

0 comments on commit fd3ce5f

Please sign in to comment.