Skip to content

WIP: Fix deep merge for container.append(). Use lodash.merge() #1475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/command/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ module.exports = function (genPath, options) {

function addAllMethodsInObject(supportObj, actions, methods, translations) {
for (const action of methodsOfObject(supportObj)) {
let fn = supportObj[action];
const fn = supportObj[action];
if (!fn.name) {
Object.defineProperty(fn, "name", {value: action});
Object.defineProperty(fn, 'name', { value: action });
}
const actionAlias = translations ? translations.actionAliasFor(action) : action;
if (!actions[actionAlias]) {
Expand Down
5 changes: 1 addition & 4 deletions lib/command/run-multiple.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
const {
getConfig, getTestRoot, fail, deepMerge,
getConfig, getTestRoot, fail,
} = require('./utils');
const Codecept = require('../codecept');
const Config = require('../config');
const fork = require('child_process').fork;
const output = require('../output');
const path = require('path');
const runHook = require('../hooks');
const event = require('../event');
Expand Down
2 changes: 0 additions & 2 deletions lib/command/run.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
const getConfig = require('./utils').getConfig;
const getTestRoot = require('./utils').getTestRoot;
const deepMerge = require('./utils').deepMerge;
const fileExists = require('../utils').fileExists;
const path = require('path');
const mkdirp = require('mkdirp');
const Config = require('../config');
const Codecept = require('../codecept');
const output = require('../output');
const event = require('../event');

module.exports = function (test, options) {
// registering options globally to use in config
Expand Down
2 changes: 1 addition & 1 deletion lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function getParams(fn) {
});
return params;
} catch (err) {
console.log('Error in ' + newFn.toString());
console.log(`Error in ${newFn.toString()}`);
console.error(err);
}
}
Expand Down
15 changes: 3 additions & 12 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,8 @@ function flatTail(flatParams, params) {
module.exports.flatTail = flatTail;

function deepMerge(target, source) {
if (isObject(target) && isObject(source)) {
for (const key in source) {
if (isObject(source[key])) {
if (!target[key]) Object.assign(target, { [key]: {} });
deepMerge(target[key], source[key]);
} else {
Object.assign(target, { [key]: source[key] });
}
}
}
return target;
const merge = require('lodash.merge');
return merge(target, source);
}

module.exports.deepMerge = deepMerge;
Expand All @@ -40,7 +31,7 @@ const isGenerator = module.exports.isGenerator = function (fn) {
};

const isFunction = module.exports.isFunction = function (fn) {
return typeof fn === 'function'
return typeof fn === 'function';
};

const isAsyncFunction = module.exports.isAsyncFunction = function (fn) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"glob": "^6.0.1",
"inquirer": "^6.2.1",
"js-beautify": "^1.8.9",
"lodash.merge": "^4.6.1",
"mkdirp": "^0.5.1",
"mocha": "^4.1.0",
"parse-function": "^5.2.10",
Expand Down