yarn icon indicating copy to clipboard operation
yarn copied to clipboard

v1.22.0: `--json` flag ignored in `yarn workspaces info` command

Open spalger opened this issue 5 years ago • 3 comments

Bug description

yarn workspaces info --json no longer works as of the v1.22.0 release. The --json flag seems to be ignored and the output is JSON wrapped in plain text. In v1.21.1 this produced a single JSON encoded object on stdout.

Command

yarn workspace info --json

What is the current behavior?

Output:

yarn workspaces v1.22.0
{
  ...
}
✨  Done in 0.08s.

What is the expected behavior?

Output:

{"type":"log","data":"{...}"}

Environment

  • Node Version: 10.18.0
  • Yarn v1 Version: 1.22.0
  • OS and version: macOS 10.15.3

spalger avatar Feb 05 '20 20:02 spalger

I think that this was an unintended effect of this: https://github.com/yarnpkg/yarn/commit/1b334e687baa75c84440def211cca0636879d14d

It still works if you move the --json flag earlier, e.g. yarn --json workspaces info

brianseeders avatar Feb 05 '20 20:02 brianseeders

this also affect the workspace cmd when running scripts.

mljsimone avatar Jul 29 '22 13:07 mljsimone

double stringified?

const result = shell.exec(`yarn --json workspaces info`, {
  silent: true
}).stdout

const workspaceInfo = JSON.parse(JSON.parse(result).data)

mashpie avatar Sep 22 '22 20:09 mashpie