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

Run shell commands in scripts #1540

Closed
jacob-horton opened this issue Feb 7, 2024 · 3 comments
Closed

Run shell commands in scripts #1540

jacob-horton opened this issue Feb 7, 2024 · 3 comments

Comments

@jacob-horton
Copy link

jacob-horton commented Feb 7, 2024

It would be really useful if we could run a shell command in the pre/post-request script. This would allow for a lot more flexibility in the scripting.

I have tried using child_process, but that doesn't appear to be accessible (as it's nodejs specific). I've looked into some npm libraries, but all the ones I came across were wrappers for child_process, so also didn't work

Is there some way to do this already that I'm missing, or if not, would it be possible to add an internal library to do this?

Thanks!

@Its-treason
Copy link
Member

You can use nodes child_process module after whitelisting it in the bruno.json of your collection like this:

{
  "scripts": {
    "moduleWhitelist": ["child_process"],
    "filesystemAccess": {
      "allow": true
    }
  }
}

Your bruno.json should look like this in the end:

{
  "version": "1",
  "name": "Test",
  "type": "collection",
  "scripts": {
    "moduleWhitelist": ["child_process"],
    "filesystemAccess": {
      "allow": true
    }
  }
}

@jacob-horton
Copy link
Author

Perfect, that's exactly what I needed, thank you!

I've made a PR in the docs repo to document this, so will close this issue 🙂

@bpoulaindev
Copy link
Contributor

@jacob-horton I'll add your PR to the new docs

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

No branches or pull requests

3 participants