Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp-env: fix syntax error where spread operator could fail #20113

merged 1 commit into from Feb 8, 2020


Copy link

noahtallen commented Feb 8, 2020

Fixes a case in the @wordpress/env logic which could try to spread false rather than an array. This was causing the error I mentioned here (albeit with a misleading error message).

In a node repl, you can see that the old syntax doesn't quite work:

$ node
$ const foo = [ ...( false && [ 1, 2, 3 ] ), 4 ];
// Thrown:
// TypeError: boolean false is not iterable (cannot read property Symbol(Symbol.iterator))


The logic now always spreads an array, rather than sometimes trying to spread false.

How has this been tested?

I ran the the wp-env start script from my own plugin. Before this patch I got undefined is not a function every time I ran the script. After this patch, the command successfully completes every time I run it, and the plugins are all mounted successfully (including the Gutenberg test plugins, since Gutenberg is a dependency.)


  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.
- There was a case where it could try to spread false
  rather than spread an array.
@noahtallen noahtallen requested review from noisysocks and epiqueras Feb 8, 2020
@noahtallen noahtallen self-assigned this Feb 8, 2020
@noahtallen noahtallen changed the title Fix syntax error where spread operator could fail wp-env: fix syntax error where spread operator could fail Feb 8, 2020
Copy link

epiqueras left a comment

Good catch!

@epiqueras epiqueras merged commit d98e695 into master Feb 8, 2020
3 checks passed
3 checks passed
Travis CI - Pull Request Build Passed
@epiqueras epiqueras deleted the fix/wordpress-env-config-array-syntax branch Feb 8, 2020
@github-actions github-actions bot added this to the Gutenberg 7.5 milestone Feb 8, 2020

This comment has been minimized.

Copy link

noisysocks commented Feb 9, 2020

Thanks for fixing @noahtallen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.