Skip to content

Commit

Permalink
fix(okam-build): fix merge not plain object not correct #23
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhy committed Dec 24, 2018
1 parent 4ed8712 commit b2214a8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/okam-build/lib/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

const helper = require('okam-helper');

function isPlainObject(obj) {
return toString.call(obj) === '[object Object]';
}

function doMerge(target, source, selector, doNotMergeSelectors) {
if (doNotMergeSelectors && doNotMergeSelectors.includes(selector)) {
return source;
Expand All @@ -24,8 +28,8 @@ function doMerge(target, source, selector, doNotMergeSelectors) {
return result;
}

let isTargetObj = !isTargetArr && target && typeof target === 'object';
let isSourceObj = !isSourceArr && source && typeof source === 'object';
let isTargetObj = !isTargetArr && isPlainObject(target);
let isSourceObj = !isSourceArr && isPlainObject(source);
if (isTargetObj && isSourceObj) {
let result = Object.assign({}, target);
Object.keys(source).forEach(k => {
Expand Down

0 comments on commit b2214a8

Please sign in to comment.