Skip to content

Commit 79b2db6

Browse files
committed
fix: handle null regex match in eject script
line.match(/ .*/g)[0] crashed with TypeError when the regex had no match and returned null. Added null-safe handling with optional chaining to prevent the crash during eject. Signed-off-by: Srikanth Patchava <spatchava@meta.com> Signed-off-by: Srikanth Patchava <srikanth.patchava@outlook.com>
1 parent 7bf2579 commit 79b2db6

12 files changed

Lines changed: 1 addition & 1 deletion

File tree

packages/create-react-app/createReactApp.js

100755100644
File mode changed.

packages/create-react-app/index.js

100755100644
File mode changed.

packages/react-scripts/bin/react-scripts.js

100755100644
File mode changed.

packages/react-scripts/scripts/eject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ prompts({
8282
'\n\n' +
8383
gitStatus
8484
.split('\n')
85-
.map(line => line.match(/ .*/g)[0].trim())
85+
.map(line => (line.match(/ .*/g) || [line])[0].trim())
8686
.join('\n') +
8787
'\n\n' +
8888
chalk.red(

tasks/e2e-behavior.sh

100755100644
File mode changed.

tasks/e2e-installs.sh

100755100644
File mode changed.

tasks/e2e-kitchensink-eject.sh

100755100644
File mode changed.

tasks/e2e-kitchensink.sh

100755100644
File mode changed.

tasks/e2e-old-node.sh

100755100644
File mode changed.

tasks/e2e-simple.sh

100755100644
File mode changed.

0 commit comments

Comments
 (0)