versioned-d.ts-tools 0.8.1 → 0.8.2
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.
- package/dist/version-remover.js +6 -0
- package/package.json +1 -1
package/dist/version-remover.js
CHANGED
|
@@ -104,11 +104,17 @@ function removeVersion(sourceDtsPath, outputFilePath, versionString, configFileP
|
|
|
104
104
|
console.warn(`Warning: Could not parse configuration file ${configFilePath}: ${error.message}`);
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
+
// Clean up extra blank lines (reduce 3+ consecutive newlines to max 2)
|
|
108
|
+
wholeDts = removeExtraBlankLines(wholeDts);
|
|
107
109
|
fsx.writeFileSync(outputFilePath, wholeDts);
|
|
108
110
|
}
|
|
109
111
|
function escapeRegExp(string) {
|
|
110
112
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
111
113
|
}
|
|
114
|
+
function removeExtraBlankLines(content) {
|
|
115
|
+
// Replace 3 or more consecutive newlines with just 2 newlines (1 blank line)
|
|
116
|
+
return content.replace(/\n{3,}/g, '\n\n');
|
|
117
|
+
}
|
|
112
118
|
// CLI entry point
|
|
113
119
|
if (require.main === module) {
|
|
114
120
|
const args = process.argv.slice(2);
|