MCPcopy Index your code
hub / github.com/nodejs/node / writeConfigurations

Function writeConfigurations

test/fixtures/snapshot/typescript.js:41324–41385  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41322 return !isCommandLineOnly && category !== undefined && (!categoriesToSkip.includes(category) || compilerOptionsMap.has(name));
41323 }
41324 function writeConfigurations() {
41325 // Filter applicable options to place in the file
41326 var categorizedOptions = ts.createMultiMap();
41327 for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
41328 var option = optionDeclarations_1[_i];
41329 var category = option.category;
41330 if (isAllowedOptionForOutput(option)) {
41331 categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
41332 }
41333 }
41334 // Serialize all options and their descriptions
41335 var marginLength = 0;
41336 var seenKnownKeys = 0;
41337 var entries = [];
41338 categorizedOptions.forEach(function (options, category) {
41339 if (entries.length !== 0) {
41340 entries.push({ value: "" });
41341 }
41342 entries.push({ value: "/* ".concat(category, " */") });
41343 for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
41344 var option = options_1[_i];
41345 var optionName = void 0;
41346 if (compilerOptionsMap.has(option.name)) {
41347 optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ",");
41348 }
41349 else {
41350 optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ",");
41351 }
41352 entries.push({
41353 value: optionName,
41354 description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */")
41355 });
41356 marginLength = Math.max(optionName.length, marginLength);
41357 }
41358 });
41359 // Write the output
41360 var tab = makePadding(2);
41361 var result = [];
41362 result.push("{");
41363 result.push("".concat(tab, "\"compilerOptions\": {"));
41364 result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */"));
41365 result.push("");
41366 // Print out each row, aligning all the descriptions on the same column.
41367 for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) {
41368 var entry = entries_2[_a];
41369 var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b;
41370 result.push(value && "".concat(tab).concat(tab).concat(value).concat(description && (makePadding(marginLength - value.length + 2) + description)));
41371 }
41372 if (fileNames.length) {
41373 result.push("".concat(tab, "},"));
41374 result.push("".concat(tab, "\"files\": ["));
41375 for (var i = 0; i < fileNames.length; i++) {
41376 result.push("".concat(tab).concat(tab).concat(JSON.stringify(fileNames[i])).concat(i === fileNames.length - 1 ? "" : ","));
41377 }
41378 result.push("".concat(tab, "]"));
41379 }
41380 else {
41381 result.push("".concat(tab, "}"));

Callers 1

generateTSConfigFunction · 0.85

Calls 11

isAllowedOptionForOutputFunction · 0.85
getDefaultValueForOptionFunction · 0.85
makePaddingFunction · 0.85
concatMethod · 0.80
addMethod · 0.65
forEachMethod · 0.65
hasMethod · 0.65
getMethod · 0.65
pushMethod · 0.45
maxMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected