Merge pull request #795 from DaPutzy/feature/additional-script-context-roots

[feature] allow multiple script context roots
This commit is contained in:
Anoop M D 2023-10-26 22:06:23 +05:30 committed by GitHub
commit 85b22b53aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -46,6 +46,11 @@ class ScriptRuntime {
const req = new BrunoRequest(request);
const allowScriptFilesystemAccess = get(scriptingConfig, 'filesystemAccess.allow', false);
const moduleWhitelist = get(scriptingConfig, 'moduleWhitelist', []);
const additionalContextRoots = get(scriptingConfig, 'additionalContextRoots', []);
const additionalContextRootsAbsolute = lodash
.chain(additionalContextRoots)
.map((acr) => (acr.startsWith('/') ? acr : path.join(collectionPath, acr)))
.value();
const whitelistedModules = {};
@ -83,7 +88,7 @@ class ScriptRuntime {
require: {
context: 'sandbox',
external: true,
root: [collectionPath],
root: [collectionPath, ...additionalContextRootsAbsolute],
mock: {
// node libs
path,

View File

@ -48,6 +48,11 @@ class TestRuntime {
const res = new BrunoResponse(response);
const allowScriptFilesystemAccess = get(scriptingConfig, 'filesystemAccess.allow', false);
const moduleWhitelist = get(scriptingConfig, 'moduleWhitelist', []);
const additionalContextRoots = get(scriptingConfig, 'additionalContextRoots', []);
const additionalContextRootsAbsolute = lodash
.chain(additionalContextRoots)
.map((acr) => (acr.startsWith('/') ? acr : path.join(collectionPath, acr)))
.value();
const whitelistedModules = {};
@ -101,7 +106,7 @@ class TestRuntime {
require: {
context: 'sandbox',
external: true,
root: [collectionPath],
root: [collectionPath, ...additionalContextRootsAbsolute],
mock: {
// node libs
path,