A better way of achieving this.

See https://github.com/wp-cli/wp-cli/pull/673/files#r5969302