@usebruno/js
Advanced tools
Comparing version 0.5.0 to 0.6.0
{ | ||
"name": "@usebruno/js", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"license": "MIT", | ||
"main": "src/index.js", | ||
@@ -21,3 +22,5 @@ "files": [ | ||
"btoa": "^1.2.1", | ||
"chai": "^4.3.7", | ||
"crypto-js": "^4.1.1", | ||
"handlebars": "^4.7.8", | ||
"json-query": "^2.2.2", | ||
@@ -24,0 +27,0 @@ "lodash": "^4.17.21", |
@@ -0,7 +1,27 @@ | ||
const Handlebars = require('handlebars'); | ||
const { cloneDeep } = require('lodash'); | ||
class Bru { | ||
constructor(envVariables, collectionVariables) { | ||
constructor(envVariables, collectionVariables, processEnvVars) { | ||
this.envVariables = envVariables; | ||
this.collectionVariables = collectionVariables; | ||
this.processEnvVars = cloneDeep(processEnvVars || {}); | ||
} | ||
_interpolateEnvVar = (str) => { | ||
if (!str || !str.length || typeof str !== 'string') { | ||
return str; | ||
} | ||
const template = Handlebars.compile(str, { noEscape: true }); | ||
return template({ | ||
process: { | ||
env: { | ||
...this.processEnvVars | ||
} | ||
} | ||
}); | ||
}; | ||
getEnvName() { | ||
@@ -12,7 +32,7 @@ return this.envVariables.__name__; | ||
getProcessEnv(key) { | ||
return process.env[key]; | ||
return this.processEnvVars[key]; | ||
} | ||
getEnvVar(key) { | ||
return this.envVariables[key]; | ||
return this._interpolateEnvVar(this.envVariables[key]); | ||
} | ||
@@ -19,0 +39,0 @@ |
@@ -24,2 +24,3 @@ const { NodeVM } = require('vm2'); | ||
const fetch = require('node-fetch'); | ||
const chai = require('chai'); | ||
const CryptoJS = require('crypto-js'); | ||
@@ -30,4 +31,12 @@ | ||
async runRequestScript(script, request, envVariables, collectionVariables, collectionPath, onConsoleLog) { | ||
const bru = new Bru(envVariables, collectionVariables); | ||
async runRequestScript( | ||
script, | ||
request, | ||
envVariables, | ||
collectionVariables, | ||
collectionPath, | ||
onConsoleLog, | ||
processEnvVars | ||
) { | ||
const bru = new Bru(envVariables, collectionVariables, processEnvVars); | ||
const req = new BrunoRequest(request); | ||
@@ -78,2 +87,3 @@ | ||
axios, | ||
chai, | ||
'node-fetch': fetch, | ||
@@ -93,4 +103,13 @@ 'crypto-js': CryptoJS | ||
async runResponseScript(script, request, response, envVariables, collectionVariables, collectionPath, onConsoleLog) { | ||
const bru = new Bru(envVariables, collectionVariables); | ||
async runResponseScript( | ||
script, | ||
request, | ||
response, | ||
envVariables, | ||
collectionVariables, | ||
collectionPath, | ||
onConsoleLog, | ||
processEnvVars | ||
) { | ||
const bru = new Bru(envVariables, collectionVariables, processEnvVars); | ||
const req = new BrunoRequest(request); | ||
@@ -97,0 +116,0 @@ const res = new BrunoResponse(response); |
@@ -23,4 +23,13 @@ const { NodeVM } = require('vm2'); | ||
runTests(testsFile, request, response, envVariables, collectionVariables, collectionPath, onConsoleLog) { | ||
const bru = new Bru(envVariables, collectionVariables); | ||
runTests( | ||
testsFile, | ||
request, | ||
response, | ||
envVariables, | ||
collectionVariables, | ||
collectionPath, | ||
onConsoleLog, | ||
processEnvVars | ||
) { | ||
const bru = new Bru(envVariables, collectionVariables, processEnvVars); | ||
const req = new BrunoRequest(request); | ||
@@ -78,2 +87,3 @@ const res = new BrunoResponse(response); | ||
nanoid, | ||
chai, | ||
'crypto-js': CryptoJS | ||
@@ -80,0 +90,0 @@ } |
@@ -7,3 +7,3 @@ const _ = require('lodash'); | ||
class VarsRuntime { | ||
runPreRequestVars(vars, request, envVariables, collectionVariables, collectionPath) { | ||
runPreRequestVars(vars, request, envVariables, collectionVariables, collectionPath, processEnvVars) { | ||
const enabledVars = _.filter(vars, (v) => v.enabled); | ||
@@ -14,3 +14,3 @@ if (!enabledVars.length) { | ||
const bru = new Bru(envVariables, collectionVariables); | ||
const bru = new Bru(envVariables, collectionVariables, processEnvVars); | ||
const req = new BrunoRequest(request); | ||
@@ -39,3 +39,3 @@ | ||
runPostResponseVars(vars, request, response, envVariables, collectionVariables, collectionPath) { | ||
runPostResponseVars(vars, request, response, envVariables, collectionVariables, collectionPath, processEnvVars) { | ||
const enabledVars = _.filter(vars, (v) => v.enabled); | ||
@@ -46,3 +46,3 @@ if (!enabledVars.length) { | ||
const bru = new Bru(envVariables, collectionVariables); | ||
const bru = new Bru(envVariables, collectionVariables, processEnvVars); | ||
const req = new BrunoRequest(request); | ||
@@ -49,0 +49,0 @@ const res = createResponseParser(response); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
26123
14
0
890
15
+ Addedchai@^4.3.7
+ Addedhandlebars@^4.7.8
+ Addedassertion-error@1.1.0(transitive)
+ Addedchai@4.5.0(transitive)
+ Addedcheck-error@1.0.3(transitive)
+ Addeddeep-eql@4.1.4(transitive)
+ Addedget-func-name@2.0.2(transitive)
+ Addedhandlebars@4.7.8(transitive)
+ Addedloupe@2.3.7(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addedpathval@1.1.1(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedtype-detect@4.1.0(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedwordwrap@1.0.0(transitive)