Skip to content

Commit 119ef00

Browse files
authored
AUI: Added parts support to anatomy import (#238)
1 parent e119f94 commit 119ef00

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "minor",
3+
"comment": "AUI: Added parts support to anatomy import",
4+
"packageName": "@adaptive-web/adaptive-ui",
5+
"email": "47367562+bheston@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

packages/adaptive-ui/src/bin/aui.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,18 @@ program.command("compile-json-anatomy <anatomyPath>")
9797
const impWithExt = imp.toLowerCase().endsWith(".json") ? imp : `${imp}.json`;
9898
const impFilePath = path.format({ ...path.parse(path.join(path.parse(jsonPath).dir, impWithExt)) });
9999
const impData = (await fsp.readFile(impFilePath)).toString();
100-
const impJsonData = JSON.parse(impData);
101-
// If `parts` are in the import, they are for validation/consistency of that file, but we want to use the parts
102-
// list from the main anatomy definition.
103-
// Consider extending this so imports can add their own known parts.
104-
delete impJsonData.parts;
100+
const impJsonData = JSON.parse(impData) as SerializableAnatomy;
101+
102+
// If `parts` are in the import, they are either for validation/consistency of that file
103+
// or additive to the main anatomy definition.
104+
// If the part selector is empty, remove it an use the value from the main anatomy definition.
105+
for (const part in impJsonData.parts) {
106+
if (impJsonData.parts.hasOwnProperty(part)) {
107+
if (impJsonData.parts[part] === "") {
108+
delete impJsonData.parts[part];
109+
}
110+
}
111+
}
105112

106113
jsonData = deepmerge(jsonData, impJsonData);
107114
}

0 commit comments

Comments
 (0)