mirror of https://github.com/Seich/Beau.git
Copy objects instead of properties on modifiers.
This commit is contained in:
parent
dd2842c097
commit
185333cb20
File diff suppressed because it is too large
Load Diff
|
|
@ -16,6 +16,7 @@
|
|||
"commander": "^2.15.1",
|
||||
"deepmerge": "^2.1.0",
|
||||
"dotenv": "^5.0.1",
|
||||
"is-plain-object": "^2.0.4",
|
||||
"js-yaml": "^3.11.0",
|
||||
"jsome": "^2.5.0",
|
||||
"request": "^2.85.0",
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@ Beau {
|
|||
"DEPENDENCIES": Set {},
|
||||
"ENDPOINT": "http://jsonplaceholder.typicode.com",
|
||||
"FORM": undefined,
|
||||
"FORMDATA": undefined,
|
||||
"HEADERS": Object {
|
||||
"authentication": "hello",
|
||||
},
|
||||
|
|
@ -224,6 +225,7 @@ Beau {
|
|||
"DEPENDENCIES": Set {},
|
||||
"ENDPOINT": "http://jsonplaceholder.typicode.com",
|
||||
"FORM": undefined,
|
||||
"FORMDATA": undefined,
|
||||
"HEADERS": Object {
|
||||
"authentication": "hello",
|
||||
"hello": "world",
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ describe(`Beau's plugin system`, () => {
|
|||
|
||||
it(`should look for dynamic values executing and replacing them`, async () => {
|
||||
let req = await request.exec(cache);
|
||||
|
||||
expect(req).toHaveProperty('request.body', 'counted 3 so far.');
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ const vm = require('vm');
|
|||
const requireg = require('requireg');
|
||||
const deepmerge = require('deepmerge');
|
||||
const { toKebabCase, dynamicValueRegex, replaceInObject } = require('./shared');
|
||||
const isPlainObject = require('is-plain-object');
|
||||
|
||||
class Plugins {
|
||||
constructor(plugins = []) {
|
||||
|
|
@ -36,7 +37,7 @@ class Plugins {
|
|||
}
|
||||
|
||||
executeModifier(modifier, obj, orig) {
|
||||
let result = deepmerge({}, obj);
|
||||
let result = deepmerge({}, obj, { isMergeableObject: isPlainObject });
|
||||
|
||||
this.registry[modifier].forEach(
|
||||
modifier => (result = modifier(result, orig))
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@ class Request {
|
|||
'PARAMS',
|
||||
'FORM',
|
||||
'ALIAS',
|
||||
'COOKIEJAR'
|
||||
'COOKIEJAR',
|
||||
'FORMDATA'
|
||||
],
|
||||
req
|
||||
);
|
||||
|
|
@ -93,6 +94,7 @@ class Request {
|
|||
qs: this.PARAMS,
|
||||
body: this.PAYLOAD,
|
||||
form: this.FORM,
|
||||
formData: this.FORMDATA,
|
||||
|
||||
json: true,
|
||||
simple: false,
|
||||
|
|
@ -103,7 +105,8 @@ class Request {
|
|||
'headers',
|
||||
'qs',
|
||||
'body',
|
||||
'form'
|
||||
'form',
|
||||
'formData'
|
||||
]);
|
||||
|
||||
settings = this.plugins.replaceDynamicValues(settings);
|
||||
|
|
|
|||
Loading…
Reference in New Issue