Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix invocation of cpplint on Windows #26040

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions script/lint.js
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