Skip to content

Commit b8745ce

Browse files
authored
Merge branch 'dev' into style-docs-preventing-horizontally-scrolling-pages
2 parents 1d28c7e + d23f5d2 commit b8745ce

File tree

36 files changed

+280
-97
lines changed

36 files changed

+280
-97
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
If you'd like to contribute to Pattern Lab Node, please do so! There is always a lot of ground to cover and something for your wheelhouse.
44

5-
No pull request is too small. Check out any [help wanted 🆘](https://github.com/pattern-lab/patternlab-node/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted+%3Asos%3A%22) or [good first issues 🎓](https://github.com/pattern-lab/patternlab-node/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue+%3Amortar_board%3A%22)as a good way to get your feet wet, or add some more unit tests.
5+
No pull request is too small. Check out any [help wanted 🆘](https://github.com/pattern-lab/patternlab-node/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted+%3Asos%3A%22) or [good first issues 🎓](https://github.com/pattern-lab/patternlab-node/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue+%3Amortar_board%3A%22) as a good way to get your feet wet, or add some more unit tests.
66

77
## Prerequisites
88

packages/cli/test/fixtures/patternlab-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"patternStateCascade": ["inprogress", "inreview", "complete"],
7373
"patternExportDirectory": "./pattern_exports/",
7474
"patternExportPatternPartials": [],
75+
"patternMergeVariantArrays": true,
7576
"serverOptions": {
7677
"wait": 1000
7778
},

packages/core/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
test
2+
.nyc_output

packages/core/docs/events.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Emitted after global `data.json` and `listitems.json` are read, and the supporti
7777
Emitted before all data is merged prior to a Pattern's render. Global `data.json` is merged with any pattern `.json`. Global `listitems.json` is merged with any pattern `.listitems.json`.
7878

7979
**Kind**: inner property of [<code>EVENTS</code>](#exp_module_Events--EVENTS)
80-
**See**: [Pattern](https://github.com/pattern-lab/patternlab-node/blob/master/src/lib/object_factory.js#L16)
80+
**See**: [Pattern](https://github.com/pattern-lab/patternlab-node/blob/master/packages/core/src/lib/object_factory.js#L16)
8181
**Properties**
8282

8383
| Name | Type | Description |
@@ -92,7 +92,7 @@ Emitted before all data is merged prior to a Pattern's render. Global `data.json
9292
Emitted before a pattern's template, HTML, and encoded HTML files are written to their output location
9393

9494
**Kind**: inner property of [<code>EVENTS</code>](#exp_module_Events--EVENTS)
95-
**See**: [Pattern](https://github.com/pattern-lab/patternlab-node/blob/master/src/lib/object_factory.js#L16)
95+
**See**: [Pattern](https://github.com/pattern-lab/patternlab-node/blob/master/packages/core/src/lib/object_factory.js#L16)
9696
**Properties**
9797

9898
| Name | Type | Description |
@@ -107,7 +107,7 @@ Emitted before a pattern's template, HTML, and encoded HTML files are written to
107107
Emitted after a pattern's template, HTML, and encoded HTML files are written to their output location
108108

109109
**Kind**: inner property of [<code>EVENTS</code>](#exp_module_Events--EVENTS)
110-
**See**: [Pattern](https://github.com/pattern-lab/patternlab-node/blob/master/src/lib/object_factory.js#L16)
110+
**See**: [Pattern](https://github.com/pattern-lab/patternlab-node/blob/master/packages/core/src/lib/object_factory.js#L16)
111111
**Properties**
112112

113113
| Name | Type | Description |

packages/core/patternlab-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"patternExportPatternPartials": [],
7676
"patternExportPreserveDirectoryStructure": true,
7777
"patternExportRaw": false,
78+
"patternMergeVariantArrays": true,
7879
"serverOptions": {
7980
"wait": 1000
8081
},

packages/core/src/lib/buildPatterns.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ module.exports = async (deletePatternDir, patternlab, additionalData) => {
5555

5656
// Flags
5757
patternlab.incrementalBuildsEnabled = !(
58-
patternlab.config.cleanPublic || graphNeedsUpgrade
58+
patternlab.config.cleanPublic ||
59+
graphNeedsUpgrade ||
60+
deletePatternDir
5961
);
6062

6163
//

packages/core/src/lib/events.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,23 @@ const EVENTS = Object.freeze({
3939
* @desc Emitted before all data is merged prior to a Pattern's render. Global `data.json` is merged with any pattern `.json`. Global `listitems.json` is merged with any pattern `.listitems.json`.
4040
* @property {object} patternlab - global data store
4141
* @property {Pattern} pattern - current pattern
42-
* @see {@link https://github.com/pattern-lab/patternlab-node/blob/master/src/lib/object_factory.js#L16|Pattern}
42+
* @see {@link https://github.com/pattern-lab/patternlab-node/blob/master/packages/core/src/lib/object_factory.js#L16|Pattern}
4343
*/
4444
PATTERNLAB_PATTERN_BEFORE_DATA_MERGE: 'patternlab-pattern-before-data-merge',
4545

4646
/**
4747
* @desc Emitted before a pattern's template, HTML, and encoded HTML files are written to their output location
4848
* @property {object} patternlab - global data store
4949
* @property {Pattern} pattern - current pattern
50-
* @see {@link https://github.com/pattern-lab/patternlab-node/blob/master/src/lib/object_factory.js#L16|Pattern}
50+
* @see {@link https://github.com/pattern-lab/patternlab-node/blob/master/packages/core/src/lib/object_factory.js#L16|Pattern}
5151
*/
5252
PATTERNLAB_PATTERN_WRITE_BEGIN: 'patternlab-pattern-write-begin',
5353

5454
/**
5555
* @desc Emitted after a pattern's template, HTML, and encoded HTML files are written to their output location
5656
* @property {object} patternlab - global data store
5757
* @property {Pattern} pattern - current pattern
58-
* @see {@link https://github.com/pattern-lab/patternlab-node/blob/master/src/lib/object_factory.js#L16|Pattern}
58+
* @see {@link https://github.com/pattern-lab/patternlab-node/blob/master/packages/core/src/lib/object_factory.js#L16|Pattern}
5959
*/
6060
PATTERNLAB_PATTERN_WRITE_END: 'patternlab-pattern-write-end',
6161

packages/core/src/lib/pseudopattern_hunter.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,24 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function(
6060
}
6161

6262
//extend any existing data with variant data
63-
variantFileData = _.merge(
63+
variantFileData = _.mergeWith(
6464
{},
6565
currentPattern.jsonFileData,
66-
variantFileData
66+
variantFileData,
67+
(objValue, srcValue) => {
68+
if (
69+
_.isArray(objValue) &&
70+
// If the parameter is not available after updating pattern lab but
71+
// not the patternlab-config it should not override arrays.
72+
patternlab.config.hasOwnProperty('patternMergeVariantArrays') &&
73+
!patternlab.config.patternMergeVariantArrays
74+
) {
75+
return srcValue;
76+
}
77+
// Lodash will only check for "undefined" and eslint needs a consistent
78+
// return so do not remove
79+
return undefined;
80+
}
6781
);
6882

6983
const variantName = pseudoPatterns[i]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"a": 1,
3+
"b": [2, 3],
4+
"c": {
5+
"d": [4, 5],
6+
"e": 8,
7+
"f": {"a": ["a"], "b": ["b"], "c": ["c"]}
8+
}
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{a}}

0 commit comments

Comments
 (0)