From f3df13b4b0e1ab575bb89f9ff4f7ec2857977cb4 Mon Sep 17 00:00:00 2001 From: David Bismut Date: Tue, 14 Mar 2017 15:11:27 +0100 Subject: [PATCH 1/2] Makes end-to-end testing crash on unhandled rejections --- packages/react-scripts/scripts/build.js | 7 +++++++ packages/react-scripts/scripts/eject.js | 7 +++++++ packages/react-scripts/scripts/init.js | 7 +++++++ packages/react-scripts/scripts/start.js | 7 +++++++ packages/react-scripts/scripts/test.js | 7 +++++++ 5 files changed, 35 insertions(+) diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 69f249f22a3..0ac0b4ad0fc 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -13,6 +13,13 @@ // Do this as the first thing so that any code reading it knows the right env. process.env.NODE_ENV = 'production'; +// Makes end-to-end testing crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + // Load environment variables from .env file. Suppress warnings using silent // if this file is missing. dotenv will never modify any environment variables // that have already been set. diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 8edc441002e..a4ef285ad0d 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -9,6 +9,13 @@ */ 'use strict'; +// Makes end-to-end testing crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + const fs = require('fs-extra'); const path = require('path'); const spawnSync = require('cross-spawn').sync; diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 9e2ea5cdcd0..58061782988 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -9,6 +9,13 @@ */ 'use strict'; +// Makes end-to-end testing crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + const fs = require('fs-extra'); const path = require('path'); const spawn = require('cross-spawn'); diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index 142a1f6d705..ace34375524 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -10,6 +10,13 @@ // @remove-on-eject-end 'use strict'; +// Makes end-to-end testing crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + process.env.NODE_ENV = 'development'; // Load environment variables from .env file. Suppress warnings using silent diff --git a/packages/react-scripts/scripts/test.js b/packages/react-scripts/scripts/test.js index e3a0094f982..f90dc7dfa54 100644 --- a/packages/react-scripts/scripts/test.js +++ b/packages/react-scripts/scripts/test.js @@ -13,6 +13,13 @@ process.env.NODE_ENV = 'test'; process.env.PUBLIC_URL = ''; +// Makes end-to-end testing crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + // Load environment variables from .env file. Suppress warnings using silent // if this file is missing. dotenv will never modify any environment variables // that have already been set. From eaf3a6479d930514872e61ef476e9ad7b66dc6f8 Mon Sep 17 00:00:00 2001 From: David Bismut Date: Tue, 14 Mar 2017 19:28:31 +0100 Subject: [PATCH 2/2] Comment fix --- packages/react-scripts/scripts/build.js | 2 +- packages/react-scripts/scripts/eject.js | 2 +- packages/react-scripts/scripts/init.js | 2 +- packages/react-scripts/scripts/start.js | 2 +- packages/react-scripts/scripts/test.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 0ac0b4ad0fc..fe4ec959d4d 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -13,7 +13,7 @@ // Do this as the first thing so that any code reading it knows the right env. process.env.NODE_ENV = 'production'; -// Makes end-to-end testing crash on unhandled rejections instead of silently +// Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. process.on('unhandledRejection', err => { diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index a4ef285ad0d..e07a57ba5e7 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -9,7 +9,7 @@ */ 'use strict'; -// Makes end-to-end testing crash on unhandled rejections instead of silently +// Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. process.on('unhandledRejection', err => { diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 58061782988..87d87e621e7 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -9,7 +9,7 @@ */ 'use strict'; -// Makes end-to-end testing crash on unhandled rejections instead of silently +// Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. process.on('unhandledRejection', err => { diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index ace34375524..12cce8ed313 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -10,7 +10,7 @@ // @remove-on-eject-end 'use strict'; -// Makes end-to-end testing crash on unhandled rejections instead of silently +// Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. process.on('unhandledRejection', err => { diff --git a/packages/react-scripts/scripts/test.js b/packages/react-scripts/scripts/test.js index f90dc7dfa54..5c395999d97 100644 --- a/packages/react-scripts/scripts/test.js +++ b/packages/react-scripts/scripts/test.js @@ -13,7 +13,7 @@ process.env.NODE_ENV = 'test'; process.env.PUBLIC_URL = ''; -// Makes end-to-end testing crash on unhandled rejections instead of silently +// Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. process.on('unhandledRejection', err => {