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

fix: make --dry=json jq and JSON.parse-friendly #894

Merged
merged 6 commits into from
Mar 17, 2022

Conversation

jaredpalmer
Copy link
Contributor

@jaredpalmer jaredpalmer commented Mar 17, 2022

Allow --dry=json's stdout can be easily jq or JSON.parse'd.

Before

import { exec } from "child_process";

exec(
  "turbo run build --scope=app --since=HEAD^ --dry=json",
  (error, stdout, stderr) => {
    if (error) {
      console.error(`exec error: ${error}`);
      return;
    }

    const { packages } = JSON.parse(stdout);
    // JSON.parse error "• Packages changed since x in scope app" invalid json
  }
);

After

import { exec } from "child_process";

exec(
  "~/dev/vercel/turbo/cli/turbo run build --scope=storefront --since=HEAD^ --dry=json",
  (error, stdout, stderr) => {
    if (error) {
      console.error(`exec error: ${error}`);
      return;
    }

    const stuff = JSON.parse(stdout);
    // no error
  }
);

@vercel
Copy link

vercel bot commented Mar 17, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/vercel/turbo-site/DgEwtvruCbE1PWF5FYAQw1r7XYZn
✅ Preview: https://turbo-site-git-jp-fixquietly-resolve-scope.vercel.sh

@jaredpalmer
Copy link
Contributor Author

(Initially i went to refactor ResolvePackages to make it a pure function, but given we are about to change everything with --filter, wasn't worth it)

@gsoltis
Copy link
Contributor

gsoltis commented Mar 17, 2022

I wouldn't mind just dropping the couple of output lines. I don't think they are adding much, since in the actual run case we print the packages in scope. We probably don't need to also repeat the user's flag values back to them.

@jaredpalmer
Copy link
Contributor Author

Fair enough

@kodiakhq kodiakhq bot merged commit 1e87849 into main Mar 17, 2022
@kodiakhq kodiakhq bot deleted the jp/fix/quietly-resolve-scope branch March 17, 2022 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants