eol.js 665 B

12345678910111213141516171819202122
  1. "use strict";
  2. /**
  3. * @license
  4. * Copyright Google LLC All Rights Reserved.
  5. *
  6. * Use of this source code is governed by an MIT-style license that can be
  7. * found in the LICENSE file at https://angular.dev/license
  8. */
  9. Object.defineProperty(exports, "__esModule", { value: true });
  10. exports.getEOL = getEOL;
  11. const node_os_1 = require("node:os");
  12. const CRLF = '\r\n';
  13. const LF = '\n';
  14. function getEOL(content) {
  15. const newlines = content.match(/(?:\r?\n)/g);
  16. if (newlines?.length) {
  17. const crlf = newlines.filter((l) => l === CRLF).length;
  18. const lf = newlines.length - crlf;
  19. return crlf > lf ? CRLF : LF;
  20. }
  21. return node_os_1.EOL;
  22. }