Skip to content

Commit 8784426

Browse files
hanslfilipesilva
authored andcommitted
ci: validate is really async and validate-commits should return errorcode
Instead of process.exit() which is a bit premature
1 parent e397bb5 commit 8784426

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

scripts/validate-commits.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ export default function (argv: ValidateCommitsOptions, logger: logging.Logger) {
145145

146146
if (invalidCount > 0) {
147147
logger.fatal(`${invalidCount} commits were found invalid...`);
148-
process.exit(1);
149148
} else {
150149
logger.info('All green. Thank you, come again.');
151150
}
151+
152+
return invalidCount;
152153
}

scripts/validate.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import validateBuildFiles from './validate-build-files';
1313
import validateCommits from './validate-commits';
1414
import validateLicenses from './validate-licenses';
1515

16-
export default function (options: { verbose: boolean }, logger: logging.Logger) {
16+
export default async function (options: { verbose: boolean }, logger: logging.Logger) {
1717
let error = false;
1818

1919
logger.info('Running templates validation...');
2020
const templateLogger = logger.createChild('templates');
2121
if (execSync(`git status --porcelain`).toString()) {
2222
logger.error('There are local changes.');
2323
if (!options.verbose) {
24-
process.exit(1);
24+
return 101;
2525
}
2626
error = true;
2727
}
@@ -44,13 +44,15 @@ export default function (options: { verbose: boolean }, logger: logging.Logger)
4444

4545
logger.info('');
4646
logger.info('Running license validation...');
47-
validateLicenses({}, logger.createChild('validate-commits'));
47+
error = await validateLicenses({}, logger.createChild('validate-commits')) != 0;
4848

4949
logger.info('');
5050
logger.info('Running BUILD files validation...');
5151
validateBuildFiles({}, logger.createChild('validate-build-files'));
5252

5353
if (error) {
54-
process.exit(101);
54+
return 101;
5555
}
56+
57+
return 0;
5658
}

0 commit comments

Comments
 (0)