@angular-devkit/core 17.1.0-next.3 → 17.1.0-rc.1
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/package.json +1 -1
- package/src/workspace/json/writer.js +13 -0
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.writeJsonWorkspace = void 0;
|
|
11
11
|
const jsonc_parser_1 = require("jsonc-parser");
|
|
12
|
+
const node_os_1 = require("node:os");
|
|
12
13
|
const metadata_1 = require("./metadata");
|
|
13
14
|
async function writeJsonWorkspace(workspace, host, path, options = {}) {
|
|
14
15
|
const metadata = workspace[metadata_1.JsonWorkspaceSymbol];
|
|
@@ -122,9 +123,21 @@ function updateJsonWorkspace(metadata) {
|
|
|
122
123
|
formattingOptions: {
|
|
123
124
|
insertSpaces: true,
|
|
124
125
|
tabSize: 2,
|
|
126
|
+
eol: getEOL(content),
|
|
125
127
|
},
|
|
126
128
|
});
|
|
127
129
|
content = (0, jsonc_parser_1.applyEdits)(content, edits);
|
|
128
130
|
}
|
|
129
131
|
return content;
|
|
130
132
|
}
|
|
133
|
+
function getEOL(content) {
|
|
134
|
+
const CRLF = '\r\n';
|
|
135
|
+
const LF = '\n';
|
|
136
|
+
const newlines = content.match(/(?:\r?\n)/g);
|
|
137
|
+
if (newlines?.length) {
|
|
138
|
+
const crlf = newlines.filter((l) => l === CRLF).length;
|
|
139
|
+
const lf = newlines.length - crlf;
|
|
140
|
+
return crlf > lf ? CRLF : LF;
|
|
141
|
+
}
|
|
142
|
+
return node_os_1.EOL;
|
|
143
|
+
}
|