From 7bf951cf3cea00ac55c39b7080a22a123012c554 Mon Sep 17 00:00:00 2001 From: Aaron Schmid Date: Fri, 25 Mar 2022 16:14:18 +0100 Subject: [PATCH] added enforceLineEndingStyle --- helpers/enforce-line-ending-style.js | 8 ++++++++ index.js | 2 ++ 2 files changed, 10 insertions(+) create mode 100644 helpers/enforce-line-ending-style.js diff --git a/helpers/enforce-line-ending-style.js b/helpers/enforce-line-ending-style.js new file mode 100644 index 0000000..32abe66 --- /dev/null +++ b/helpers/enforce-line-ending-style.js @@ -0,0 +1,8 @@ +const { EOL } = require('os') +const newlineRe = /(\r\n|\r|\n)/g + +function enforceLineEndingStyle(content) { + return content.replaceAll(newlineRe, EOL) +} + +module.exports = enforceLineEndingStyle diff --git a/index.js b/index.js index a3af587..892bd1d 100755 --- a/index.js +++ b/index.js @@ -11,6 +11,7 @@ const { deduplicateSolidityExpHeaders, deduplicateLicenses } = require('./helpers/deduplicate-lines') +const enforceLineEndingStyle = require('./helpers/enforce-line-ending-style') flatten() @@ -35,6 +36,7 @@ async function getSourceFiles(dir, path) { async function replaceImports(inputFileContent, dir) { let outputFileContent = await replaceAllImportsRecursively(inputFileContent, dir) + outputFileContent = enforceLineEndingStyle(outputFileContent) outputFileContent = deduplicateLicenses(outputFileContent) outputFileContent = deduplicateSolidityVersoins(outputFileContent) outputFileContent = deduplicateSolidityExpHeaders(outputFileContent)