Skip to content

Commit 9adcc28

Browse files
committed
fix: duplicate flag descriptions
1 parent 1560bcd commit 9adcc28

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/ditamap/command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class Command extends Ditamap {
117117
if (flag.hidden) continue;
118118
const description = Array.isArray(flag.description) ? flag.description.join('\n') : flag.description || '';
119119
const entireDescription = flag.summary ? `${flag.summary}\n${description}` : description;
120-
const updated = Object.assign(flag, {
120+
const updated = Object.assign({}, flag, {
121121
name: flagName,
122122
description: this.formatParagraphs(entireDescription),
123123
optional: !flag.required,

src/docs.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,14 @@ export class Docs {
7373
const commandIds = [];
7474

7575
for (const subtopic of Object.keys(subtopics)) {
76-
const subtopicOrCommand = subtopics[subtopic];
76+
const subtopicOrCommand = isArray(subtopics[subtopic])
77+
? Object.assign([], subtopics[subtopic])
78+
: Object.assign({}, subtopics[subtopic]);
79+
7780
try {
7881
if (!isArray(subtopicOrCommand)) {
7982
// If it is not subtopic (array) it is a command in the top-level topic
80-
const command = subtopicOrCommand;
83+
const command = Object.assign({}, subtopicOrCommand);
8184
const commandMeta = this.resolveCommandMeta(ensureString(command.id), command, 1);
8285
await this.populateCommand(topic, null, command, commandMeta);
8386
commandIds.push(command.id);
@@ -212,7 +215,7 @@ export class Docs {
212215
}
213216

214217
// Collect all tiers of the meta, so the command will also pick up the topic state (isPilot, etc) if applicable
215-
Object.assign(commandMeta, currentMeta);
218+
Object.assign({}, commandMeta, currentMeta);
216219
}
217220
} catch (error) {
218221
if (commandId.endsWith(part)) {

0 commit comments

Comments
 (0)