Skip to content

Commit d3c600f

Browse files
committed
Adding new --fail-on-errors option to return a non-zero error code
1 parent 5def2fe commit d3c600f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/Command/BuildDocsCommand.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ protected function configure()
8585
InputOption::VALUE_NONE,
8686
'Use the default theme instead of the styled one'
8787
)
88+
->addOption(
89+
'fail-on-errors',
90+
null,
91+
InputOption::VALUE_NONE,
92+
'Return a non-zero code if there are errors/warnings'
93+
)
8894
;
8995
}
9096

@@ -166,8 +172,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
166172

167173
$this->io->newLine(2);
168174

169-
$successMessage = 'Build complete!';
170-
$this->io->success($successMessage);
175+
if (\count($buildErrors) > 0) {
176+
$this->io->success('Build completed with warnings');
177+
178+
if ($input->getOption('fail-on-errors')) {
179+
return 1;
180+
}
181+
} else {
182+
$this->io->success('Build completed successfully!');
183+
}
171184

172185
return 0;
173186
}

0 commit comments

Comments
 (0)