Skip to content

Commit

Permalink
fix: deep merge objects when extending package.json via plugins (#1070)
Browse files Browse the repository at this point in the history
close #1053
  • Loading branch information
dhensche authored and yyx990803 committed Apr 25, 2018
1 parent cac18f2 commit 6af7bbe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 15 additions & 3 deletions packages/@vue/cli/__tests__/Generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ test('api: extendPackage', async () => {
list: [1],
vue: {
foo: 1,
bar: 2
bar: 2,
pluginOptions: {
graphqlMock: true,
apolloEngine: false
}
}
},
plugins: [{
Expand All @@ -60,7 +64,10 @@ test('api: extendPackage', async () => {
list: [2],
vue: {
foo: 2,
baz: 3
baz: 3,
pluginOptions: {
enableInSFC: true
}
}
})
}
Expand All @@ -76,7 +83,12 @@ test('api: extendPackage', async () => {
vue: {
foo: 2,
bar: 2,
baz: 3
baz: 3,
pluginOptions: {
graphqlMock: true,
apolloEngine: false,
enableInSFC: true
}
}
})
})
Expand Down
3 changes: 2 additions & 1 deletion packages/@vue/cli/lib/GeneratorAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 6af7bbe

Please sign in to comment.