node-wp-cli
node-wp-cli copied to clipboard
Correct handling of format argument
It looks like there's a mistake in the format logic, resulting in the format always being set to json.
This code appears in utils.js, perhaps it should be if(!flags.format)?
if(flags.format)
flags.format="json";
The nett result is that when running an option update call:
wp.option.update(["show_on_front","page"], { }, function(err,result) {
I get "Error: Invalid JSON: page" - providing a different format (e.g. format: "count" ) doesn't work because the code above overrides it to json.
I'm not sure if it's related to this - I suspect it is - but when running eg. wp.search_replace()
I'm hitting an invalid JSON parse. node-wp-cli is expecting JSON back, but wp-cli's default format for this command is 'table'.
In fact, unfortunately, json doesn't seem to be a valid format for this command, so that makes it a little difficult to use :(
(I'm fairly sure this used to be working for me, but on coming back to a project a bit later it no longer is, so this may have been due to changes in wp-cli).