Skip to content

Commit b8bb7c6

Browse files
committed
fixed smoke test
1 parent 4cc09f4 commit b8bb7c6

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

packages/react-dev-utils/WebpackDevServerUtils.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ const getProcessForPort = require('./getProcessForPort');
2020
const typescriptFormatter = require('./typescriptFormatter');
2121

2222
const isInteractive = process.stdout.isTTY;
23-
let handleCompile;
24-
25-
// You can safely remove this after ejecting.
26-
// We only use this block for testing of Create React App itself:
27-
const isSmokeTest = process.argv.some(arg => arg.indexOf('--smoke-test') > -1);
28-
if (isSmokeTest) {
29-
handleCompile = (err, stats) => {
30-
if (err || stats.hasErrors() || stats.hasWarnings()) {
31-
process.exit(1);
32-
} else {
33-
process.exit(0);
34-
}
35-
};
36-
}
3723

3824
function prepareUrls(protocol, host, port) {
3925
const formatUrl = hostname =>
@@ -119,7 +105,7 @@ function createCompiler(webpack, config, appName, urls, useYarn, useTypeScript,
119105
// It lets us listen to some events and provide our own custom messages.
120106
let compiler;
121107
try {
122-
compiler = webpack(config, handleCompile);
108+
compiler = webpack(config);
123109
} catch (err) {
124110
console.log(chalk.red('Failed to compile.'));
125111
console.log();
@@ -128,6 +114,20 @@ function createCompiler(webpack, config, appName, urls, useYarn, useTypeScript,
128114
process.exit(1);
129115
}
130116

117+
// You can safely remove this after ejecting.
118+
// We only use this block for testing of Create React App itself:
119+
const isSmokeTest = process.argv.some(arg => arg.indexOf('--smoke-test') > -1);
120+
if (isSmokeTest) {
121+
compiler.hooks.failed.tap('smokeTest', () => process.exit(1));
122+
compiler.hooks.done.tap('smokeTest', stats => {
123+
if (stats.hasErrors() || stats.hasWarnings()) {
124+
process.exit(1);
125+
} else {
126+
process.exit(0);
127+
}
128+
});
129+
}
130+
131131
// "invalid" event fires when you have changed a file, and Webpack is
132132
// recompiling a bundle. WebpackDevServer takes care to pause serving the
133133
// bundle, so if you refresh, it'll wait instead of serving the old one.

0 commit comments

Comments
 (0)