Skip to content

Commit fd248f7

Browse files
committed
Configure to fail CI on error or warning
1 parent 483e631 commit fd248f7

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

packages/react-error-overlay/build.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
* LICENSE file in the root directory of this source tree. An additional grant
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
9-
'use strict';
10-
119
const webpack = require('webpack');
1210
const chalk = require('chalk');
1311
const webpackConfig = require('./webpack.config.js');
@@ -18,27 +16,40 @@ const chokidar = require('chokidar');
1816
const args = process.argv.slice(2);
1917
const watchMode = args[0] === '--watch' || args[0] === '-w';
2018

19+
const isCI =
20+
process.env.CI &&
21+
(typeof process.env.CI !== 'string' ||
22+
process.env.CI.toLowerCase() !== 'false');
23+
2124
function build(config, name, callback) {
2225
console.log(chalk.cyan('Compiling ' + name));
2326
webpack(config).run((error, stats) => {
2427
if (error) {
2528
console.log(chalk.red('Failed to compile.'));
2629
console.log(error.message || error);
2730
console.log();
28-
return;
2931
}
3032

3133
if (stats.compilation.errors.length) {
3234
console.log(chalk.red('Failed to compile.'));
3335
console.log(stats.toString({ all: false, errors: true }));
34-
return;
3536
}
3637

3738
if (stats.compilation.warnings.length) {
3839
console.log(chalk.yellow('Compiled with warnings.'));
3940
console.log(stats.toString({ all: false, warnings: true }));
4041
}
4142

43+
// Fail the build if running in a CI server
44+
if (
45+
error ||
46+
stats.compilation.errors.length ||
47+
stats.compilation.warnings.length
48+
) {
49+
isCI && process.exit(1);
50+
return;
51+
}
52+
4253
console.log(
4354
stats.toString({ colors: true, modules: false, version: false })
4455
);
@@ -51,9 +62,7 @@ function build(config, name, callback) {
5162
function runBuildSteps() {
5263
build(iframeWebpackConfig, 'iframeScript.js', () => {
5364
build(webpackConfig, 'index.js', () => {
54-
console.log(chalk.bold.green('Compiled successfully!'));
55-
console.log();
56-
console.log();
65+
console.log(chalk.bold.green('Compiled successfully!\n\n'));
5766
});
5867
});
5968
}
@@ -83,7 +92,6 @@ function setupWatch() {
8392

8493
// Clean up lib folder
8594
rimraf('lib/', () => {
86-
console.log('Cleaned up the lib folder.');
87-
console.log();
95+
console.log('Cleaned up the lib folder.\n');
8896
watchMode ? setupWatch() : runBuildSteps();
8997
});

packages/react-error-overlay/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
"dependencies": {
3434
"anser": "1.4.1",
3535
"babel-code-frame": "6.22.0",
36-
"babel-loader": "^7.1.2",
3736
"babel-runtime": "6.26.0",
3837
"html-entities": "1.2.1",
3938
"object-assign": "^4.1.1",
@@ -47,6 +46,7 @@
4746
"devDependencies": {
4847
"babel-eslint": "7.2.3",
4948
"babel-preset-react-app": "^3.0.3",
49+
"babel-loader": "^7.1.2",
5050
"chalk": "^2.1.0",
5151
"chokidar": "^1.7.0",
5252
"cross-env": "5.0.5",

packages/react-error-overlay/src/utils/pollyfills.js

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
* LICENSE file in the root directory of this source tree. An additional grant
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
9-
'use strict';
10-
119
if (typeof Promise === 'undefined') {
1210
// Rejection tracking prevents a common issue where React gets into an
1311
// inconsistent state due to an error, but it gets swallowed by a Promise,

0 commit comments

Comments
 (0)