Skip to content

Is it possible to get the current request name via script? #954

Closed Answered by n00o
CoenraadS asked this question in Q&A
Discussion options

You must be logged in to vote

I looked into this and it seems that there is no way to get the name easily but you can kind of get around it by reading every file in the current working directory and look for the name there.

To do this you will need to turn on the node library fs by going to your the bruno.json file in your collection folder and adding this element:

"scripts": {
  "filesystemAccess": {
    "allow": true
  }
 }

Then in your collection folder add this snippet to the post-script:

const fs = require("fs");
const path = require("path");
const dir = path.join(bru.cwd());
const getAllFiles = function(dirPath, arrayOfFiles) {
  files = fs.readdirSync(dirPath);
  arrayOfFiles = arrayOfFiles || [];
  files.forEach(

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@CoenraadS
Comment options

Answer selected by CoenraadS
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants