usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.26k stars 1.25k forks source link

Cannot run a script file in parent folder #3384

Open Nizoryu opened 2 weeks ago

Nizoryu commented 2 weeks ago

I have checked the following:

Describe the bug

I have no problem running my script from the root folder of the collection.

bruno/
├── demo/
    └── environnements
    └── bruno.json
    └── get demo.bru
    └── script.js

When I move the file to the parent folder like this:

bruno/
├── demo/
    └── environnements
    └── bruno.json
    └── get demo.bru
└── script.js

i have this issue: Error invoking remote method 'send-http-request': VMError: Cannot find module '../script.js'

.bru file to reproduce the bug

meta { name: get demo type: http seq: 2 }

get { url: http://localhost:3000 body: none auth: none }

script:pre-request { const script = require("../script.js"); // const moment = require('moment');

console.log(bru.getVar('today')); }

Screenshots/Live demo link

image

sreelakshmi-bruno commented 1 week ago

Hi @Nizoryu, access to files outside of the collection path is not allowed in Bruno. When doing so you'll get an error message saying 'Error: Access to files outside of the collectionPath is not allowed'. I'm not sure why you are getting a 'Cannot find module' message. Can you check again and get back? Thanks! Also from the file structure you've shown, I assume 'demo' as your collection.

Related to #1397 and #795

sreelakshmi-bruno commented 1 week ago

Could you share your use case? Are you looking to share a common script file across multiple collections?