diff --git a/packages/cli/test/fixtures/patternlab-config.json b/packages/cli/test/fixtures/patternlab-config.json index 6102f522f3..4bd371e264 100644 --- a/packages/cli/test/fixtures/patternlab-config.json +++ b/packages/cli/test/fixtures/patternlab-config.json @@ -72,6 +72,7 @@ "patternStateCascade": ["inprogress", "inreview", "complete"], "patternExportDirectory": "./pattern_exports/", "patternExportPatternPartials": [], + "patternMergeVariantArrays": true, "serverOptions": { "wait": 1000 }, diff --git a/packages/core/patternlab-config.json b/packages/core/patternlab-config.json index 39eed54fd3..28d62a2d00 100644 --- a/packages/core/patternlab-config.json +++ b/packages/core/patternlab-config.json @@ -75,6 +75,7 @@ "patternExportPatternPartials": [], "patternExportPreserveDirectoryStructure": true, "patternExportRaw": false, + "patternMergeVariantArrays": true, "serverOptions": { "wait": 1000 }, diff --git a/packages/core/src/lib/pseudopattern_hunter.js b/packages/core/src/lib/pseudopattern_hunter.js index b95dd37f1d..8a4cb4adc7 100644 --- a/packages/core/src/lib/pseudopattern_hunter.js +++ b/packages/core/src/lib/pseudopattern_hunter.js @@ -60,10 +60,21 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function( } //extend any existing data with variant data - variantFileData = _.merge( + variantFileData = _.mergeWith( {}, currentPattern.jsonFileData, - variantFileData + variantFileData, + (objValue, srcValue) => { + if ( + _.isArray(objValue) && + patternlab.config.patternMergeVariantArrays + ) { + return objValue.concat(srcValue); + } + // Lodash will only check for "undefined" and eslint needs a consistent + // return so do not remove + return undefined; + } ); const variantName = pseudoPatterns[i] diff --git a/packages/core/test/util/patternlab-config.json b/packages/core/test/util/patternlab-config.json index c2edf9561c..904e37afde 100644 --- a/packages/core/test/util/patternlab-config.json +++ b/packages/core/test/util/patternlab-config.json @@ -57,6 +57,7 @@ "patternExportPatternPartials": [], "patternExportDirectory": "./pattern_exports/", "patternExtension": "mustache", + "patternMergeVariantArrays": true, "cacheBust": true, "outputFileSuffixes": { "rendered": ".rendered", diff --git a/packages/development-edition-engine-handlebars/patternlab-config.json b/packages/development-edition-engine-handlebars/patternlab-config.json index 5b9e9a0c2c..141f35a47d 100644 --- a/packages/development-edition-engine-handlebars/patternlab-config.json +++ b/packages/development-edition-engine-handlebars/patternlab-config.json @@ -70,6 +70,7 @@ "patternExportPatternPartials": [], "patternExportPreserveDirectoryStructure": true, "patternExportRaw": false, + "patternMergeVariantArrays": true, "serverOptions": { "wait": 1000 }, diff --git a/packages/development-edition-engine-react/patternlab-config.json b/packages/development-edition-engine-react/patternlab-config.json index 23b459f2db..dd4efbd247 100644 --- a/packages/development-edition-engine-react/patternlab-config.json +++ b/packages/development-edition-engine-react/patternlab-config.json @@ -25,16 +25,7 @@ "m": [500, 800], "l": [800, 2600] }, -<<<<<<< HEAD:packages/development-edition-engine-react/patternlab-config.json "logLevel": "info", -======= - "patternExportAll": false, - "patternExportPreserveDirectoryStructure": false, - "patternExportRaw": false, - "patternExportPatternPartials": [], - "patternExportDirectory": "./pattern_exports/", - "cacheBust": true, ->>>>>>> 436dd99e50d808cd14691593b927209f1ecb663e:patternlab-config.json "outputFileSuffixes": { "rendered": ".rendered", "rawTemplate": "", @@ -79,8 +70,12 @@ }, "patternExtension": "mustache", "patternStateCascade": ["inprogress", "inreview", "complete"], + "patternExportAll": false, + "patternExportPreserveDirectoryStructure": false, + "patternExportRaw": false, "patternExportDirectory": "./pattern_exports/", "patternExportPatternPartials": [], + "patternMergeVariantArrays": true, "serverOptions": { "wait": 1000 }, diff --git a/packages/development-edition-engine-twig/patternlab-config.json b/packages/development-edition-engine-twig/patternlab-config.json index 3c18bd4039..55fed5c95b 100644 --- a/packages/development-edition-engine-twig/patternlab-config.json +++ b/packages/development-edition-engine-twig/patternlab-config.json @@ -80,6 +80,7 @@ ], "patternExportDirectory": "pattern_exports", "patternExportPatternPartials": [], + "patternMergeVariantArrays": true, "serverOptions": { "wait": 1000 }, diff --git a/packages/edition-node-gulp/patternlab-config.json b/packages/edition-node-gulp/patternlab-config.json index 20625a44fe..e24473a028 100644 --- a/packages/edition-node-gulp/patternlab-config.json +++ b/packages/edition-node-gulp/patternlab-config.json @@ -75,6 +75,7 @@ "patternExportPatternPartials": [], "patternExportPreserveDirectoryStructure": true, "patternExportRaw": false, + "patternMergeVariantArrays": true, "serverOptions": { "wait": 1000 }, diff --git a/packages/edition-node/patternlab-config.json b/packages/edition-node/patternlab-config.json index e5cef68117..3112f5ac08 100644 --- a/packages/edition-node/patternlab-config.json +++ b/packages/edition-node/patternlab-config.json @@ -75,6 +75,7 @@ "patternExportPatternPartials": [], "patternExportPreserveDirectoryStructure": true, "patternExportRaw": false, + "patternMergeVariantArrays": true, "serverOptions": { "wait": 1000 }, diff --git a/packages/edition-twig/patternlab-config.json b/packages/edition-twig/patternlab-config.json index e9652bde5a..ee6acd691c 100644 --- a/packages/edition-twig/patternlab-config.json +++ b/packages/edition-twig/patternlab-config.json @@ -139,6 +139,7 @@ "patternExportPatternPartials": [], "patternExportPreserveDirectoryStructure": true, "patternExportRaw": false, + "patternMergeVariantArrays": true, "serverOptions": { "wait": 1000 },