abi-gen: exit when black fails to parse Python
Note: this is not the same case as when the black executable can't be found; that case is still just a (non-fatal) warning.
This commit is contained in:
parent
79b6c3c1af
commit
277fb92f9e
@ -277,10 +277,16 @@ for (const abiFileName of abiFileNames) {
|
||||
// use command-line tool black to reformat, if its available
|
||||
try {
|
||||
execSync(`black --line-length 79 ${outFilePath}`);
|
||||
} catch {
|
||||
logUtils.warn(
|
||||
'Failed to reformat generated Python with black. Do you have it installed? Proceeding anyways...',
|
||||
);
|
||||
} catch (e) {
|
||||
const BLACK_RC_CANNOT_PARSE = 123; // empirical black exit code
|
||||
if (e.status === BLACK_RC_CANNOT_PARSE) {
|
||||
logUtils.warn(
|
||||
'Failed to reformat generated Python with black. Exception thrown by execSync("black ...") follows.',
|
||||
);
|
||||
throw e;
|
||||
} else {
|
||||
logUtils.warn('Failed to invoke black. Do you have it installed? Proceeding anyways...');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user