fix: deep merge objects when extending package.json via plugins (#1070)

close #1053
This commit is contained in:
Derek Henscheid
2018-04-25 16:53:06 -05:00
committed by Evan You
parent cac18f231e
commit 6af7bbe247
2 changed files with 17 additions and 4 deletions
+15 -3
View File
@@ -49,7 +49,11 @@ test('api: extendPackage', async () => {
list: [1],
vue: {
foo: 1,
bar: 2
bar: 2,
pluginOptions: {
graphqlMock: true,
apolloEngine: false
}
}
},
plugins: [{
@@ -60,7 +64,10 @@ test('api: extendPackage', async () => {
list: [2],
vue: {
foo: 2,
baz: 3
baz: 3,
pluginOptions: {
enableInSFC: true
}
}
})
}
@@ -76,7 +83,12 @@ test('api: extendPackage', async () => {
vue: {
foo: 2,
bar: 2,
baz: 3
baz: 3,
pluginOptions: {
graphqlMock: true,
apolloEngine: false,
enableInSFC: true
}
}
})
})
+2 -1
View File
@@ -2,6 +2,7 @@ const fs = require('fs')
const ejs = require('ejs')
const path = require('path')
const globby = require('globby')
const merge = require('deepmerge')
const resolve = require('resolve')
const isBinary = require('isbinaryfile')
const yaml = require('yaml-front-matter')
@@ -105,7 +106,7 @@ class GeneratorAPI {
} else if (Array.isArray(value) && Array.isArray(existing)) {
pkg[key] = existing.concat(value)
} else if (isObject(value) && isObject(existing)) {
pkg[key] = Object.assign({}, existing, value)
pkg[key] = merge(existing, value)
} else {
pkg[key] = value
}