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

Non-0 exit code when comparison detects changes #505

Open
dargmuesli opened this issue Aug 3, 2021 · 4 comments · May be fixed by #591
Open

Non-0 exit code when comparison detects changes #505

dargmuesli opened this issue Aug 3, 2021 · 4 comments · May be fixed by #591

Comments

@dargmuesli
Copy link

Hey there, would it be possible to let reg-suit compare exit with a non-0 exit code when changes are detected? This way it's easy for scripts to decide whether to continue, e.g. CI systems could then fail the build. Other tools like Creevey already work like this. Alternatively, how could I detect that reg-suit compare detected changes?

@maniator
Copy link

Anyone know if this is being worked on?

@dargmuesli
Copy link
Author

If noone said so, I guess not.
I've created a shell script that uses jq to check out.json for changes as a workaround:
https://github.com/maevsi/maevsi/blob/742dfd1e9906c1d590254f2423f9e3f07989f9c8/nuxt/.storybook/storycap/test.sh#L12-L51

maniator added a commit to maniator/reg-suit that referenced this issue Aug 11, 2022
@maniator maniator linked a pull request Aug 11, 2022 that will close this issue
@maniator
Copy link

@dargmuesli #591

@maniator
Copy link

@dargmuesli I wrote something in node (modeled after your code)

const jq = require('node-jq');
const path = require('path');

const outJson = path.join(__dirname, 'working-directory/out.json');

async function runCheck() {
  const failedItems = await jq.run('.failedItems[]', outJson, {});
  if (failedItems.length) {
    console.error('You have diff changes, please view them');
  }

  const newItems = await jq.run('.newItems[]', outJson, {});
  if (newItems.length) {
    console.error('You have new items, please view them');
  }

  const deletedItems = await jq.run('.deletedItems[]', outJson, {});
  if (deletedItems.length) {
    console.error('You have deleted items, please view them');
  }

  if (failedItems.length || deletedItems.length || newItems.length) {
    console.error('Run "npm run view:diff" to view');
    console.error(
      'If you are satisfied with the changes, run "npm run diff:approve"',
    );
    process.exit(1);
  }
}

runCheck().catch((err) => {
  console.error(err);
  process.exit(1);
});

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 a pull request may close this issue.

2 participants