mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-09 07:28:24 +01:00
feat: allow multiple script context roots
This commit is contained in:
parent
7f7b3f479a
commit
7fa68731d2
@ -46,6 +46,11 @@ class ScriptRuntime {
|
|||||||
const req = new BrunoRequest(request);
|
const req = new BrunoRequest(request);
|
||||||
const allowScriptFilesystemAccess = get(scriptingConfig, 'filesystemAccess.allow', false);
|
const allowScriptFilesystemAccess = get(scriptingConfig, 'filesystemAccess.allow', false);
|
||||||
const moduleWhitelist = get(scriptingConfig, 'moduleWhitelist', []);
|
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 = {};
|
const whitelistedModules = {};
|
||||||
|
|
||||||
@ -83,7 +88,7 @@ class ScriptRuntime {
|
|||||||
require: {
|
require: {
|
||||||
context: 'sandbox',
|
context: 'sandbox',
|
||||||
external: true,
|
external: true,
|
||||||
root: [collectionPath],
|
root: [collectionPath, ...additionalContextRootsAbsolute],
|
||||||
mock: {
|
mock: {
|
||||||
// node libs
|
// node libs
|
||||||
path,
|
path,
|
||||||
|
@ -48,6 +48,11 @@ class TestRuntime {
|
|||||||
const res = new BrunoResponse(response);
|
const res = new BrunoResponse(response);
|
||||||
const allowScriptFilesystemAccess = get(scriptingConfig, 'filesystemAccess.allow', false);
|
const allowScriptFilesystemAccess = get(scriptingConfig, 'filesystemAccess.allow', false);
|
||||||
const moduleWhitelist = get(scriptingConfig, 'moduleWhitelist', []);
|
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 = {};
|
const whitelistedModules = {};
|
||||||
|
|
||||||
@ -101,7 +106,7 @@ class TestRuntime {
|
|||||||
require: {
|
require: {
|
||||||
context: 'sandbox',
|
context: 'sandbox',
|
||||||
external: true,
|
external: true,
|
||||||
root: [collectionPath],
|
root: [collectionPath, ...additionalContextRootsAbsolute],
|
||||||
mock: {
|
mock: {
|
||||||
// node libs
|
// node libs
|
||||||
path,
|
path,
|
||||||
|
Loading…
Reference in New Issue
Block a user