declapract-typescript-ehmpathy 0.47.36 → 0.47.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -101,26 +101,26 @@ const ensureSection = (
|
|
|
101
101
|
): string => {
|
|
102
102
|
const lines = content.split('\n');
|
|
103
103
|
|
|
104
|
+
// find which entries are absent from the content
|
|
105
|
+
const entriesAbsent = section.entries.latest.filter(
|
|
106
|
+
(entry) => !content.includes(entry),
|
|
107
|
+
);
|
|
108
|
+
|
|
104
109
|
// find the header line index
|
|
105
110
|
const headerIndex = lines.findIndex(
|
|
106
111
|
(line) => line.trim() === section.header.latest,
|
|
107
112
|
);
|
|
108
113
|
|
|
109
|
-
// if header not found, append
|
|
114
|
+
// if header not found, append header and only absent entries
|
|
110
115
|
if (headerIndex === -1) {
|
|
111
116
|
return (
|
|
112
117
|
content.trimEnd() +
|
|
113
118
|
'\n\n' +
|
|
114
|
-
[section.header.latest, ...
|
|
119
|
+
[section.header.latest, ...entriesAbsent].join('\n') +
|
|
115
120
|
'\n'
|
|
116
121
|
);
|
|
117
122
|
}
|
|
118
123
|
|
|
119
|
-
// find which entries are absent
|
|
120
|
-
const entriesAbsent = section.entries.latest.filter(
|
|
121
|
-
(entry) => !content.includes(entry),
|
|
122
|
-
);
|
|
123
|
-
|
|
124
124
|
// if all entries present, no fix required
|
|
125
125
|
if (entriesAbsent.length === 0) return content;
|
|
126
126
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "declapract-typescript-ehmpathy",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "declapract best practices declarations for typescript",
|
|
5
|
-
"version": "0.47.
|
|
5
|
+
"version": "0.47.37",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|