Skip to content

Commit 736ebd1

Browse files
committed
build: better validation logging and does not break if verbose
1 parent 606e530 commit 736ebd1

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

scripts/validate-commits.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ export default function (_: {}, logger: Logger) {
3232
.toString().trim();
3333
sha = 'HEAD';
3434
}
35-
logger.info(' Base: ' + baseSha);
36-
logger.info(' HEAD: ' + sha);
35+
36+
logger.createChild('sha').info(`Base: ${baseSha}\nHEAD: ${sha}`);
3737

3838
const log = execSync(`git log --oneline "${baseSha}..${sha}"`).toString().trim();
3939
logger.debug('Commits:');
40-
logger.debug(' ' + log.split(/\n/).join('\n '));
40+
logger.createChild('commits').debug(log);
4141
logger.debug('');
4242

4343
const commits = log.split(/\n/)

scripts/validate.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,35 @@ import { execSync } from 'child_process';
1010
import templates from './templates';
1111
import validateCommits from './validate-commits';
1212

13-
export default function (_: {}, logger: Logger) {
14-
logger.info('Running templates validation...');
13+
export default function (options: { verbose: boolean }, logger: Logger) {
14+
let error = false;
1515

16+
logger.info('Running templates validation...');
17+
const templateLogger = logger.createChild('templates');
1618
if (execSync(`git status --porcelain`).toString()) {
17-
logger.fatal('There are local changes...');
18-
process.exit(1);
19+
logger.error('There are local changes.');
20+
if (!options.verbose) {
21+
process.exit(1);
22+
}
23+
error = true;
1924
}
20-
templates({}, logger.createChild('templates'));
25+
templates({}, templateLogger);
2126
if (execSync(`git status --porcelain`).toString()) {
22-
logger.fatal(tags.oneLine`
27+
logger.error(tags.oneLine`
2328
Running templates updated files... Please run "devkit-admin templates" before submitting
2429
a PR.
2530
`);
26-
process.exit(2);
31+
if (!options.verbose) {
32+
process.exit(2);
33+
}
34+
error = true;
2735
}
2836

37+
logger.info('');
2938
logger.info('Running commit validation...');
3039
validateCommits({}, logger.createChild('validate-commits'));
40+
41+
if (error) {
42+
process.exit(101);
43+
}
3144
}

0 commit comments

Comments
 (0)