@usebruno/js 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usebruno/js",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "license": "MIT",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -1,4 +1,5 @@
1
1
  const { get } = require('@usebruno/query');
2
+ const _ = require('lodash');
2
3
 
3
4
  class BrunoResponse {
4
5
  constructor(res) {
@@ -46,8 +47,9 @@ class BrunoResponse {
46
47
  return;
47
48
  }
48
49
 
49
- this.body = data;
50
- this.res.data = data;
50
+ const clonedData = _.cloneDeep(data);
51
+ this.res.data = clonedData;
52
+ this.body = clonedData;
51
53
  }
52
54
  }
53
55
 
@@ -207,6 +207,11 @@ class ScriptRuntime {
207
207
  const res = new BrunoResponse(response);
208
208
  const allowScriptFilesystemAccess = get(scriptingConfig, 'filesystemAccess.allow', false);
209
209
  const moduleWhitelist = get(scriptingConfig, 'moduleWhitelist', []);
210
+ const additionalContextRoots = get(scriptingConfig, 'additionalContextRoots', []);
211
+ const additionalContextRootsAbsolute = lodash
212
+ .chain(additionalContextRoots)
213
+ .map((acr) => (acr.startsWith('/') ? acr : path.join(collectionPath, acr)))
214
+ .value();
210
215
 
211
216
  const whitelistedModules = {};
212
217
 
@@ -270,7 +275,7 @@ class ScriptRuntime {
270
275
  context: 'sandbox',
271
276
  builtin: [ "*" ],
272
277
  external: true,
273
- root: [collectionPath],
278
+ root: [collectionPath, ...additionalContextRootsAbsolute],
274
279
  mock: {
275
280
  // node libs
276
281
  path,