From d0b280a67ba6164ad3e567c32cdacaed9dd552d4 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Fri, 16 Oct 2020 18:25:59 -0700 Subject: [PATCH] build: fix invocation of cpplint on Windows --- script/lint.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/script/lint.js b/script/lint.js index 103265b89a3fc..b92d2d620bf54 100755 --- a/script/lint.js +++ b/script/lint.js @@ -23,6 +23,8 @@ 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; @@ -30,7 +32,7 @@ function spawnAndCheckExitCode (cmd, args, opts) { } 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]+/)) { @@ -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); } }