fix(yaml viewer): handle numbers as bigint to avoid conversion to exponent

This commit is contained in:
ShareVB 2024-12-30 17:30:49 +01:00
parent e68f743147
commit ab6609ef7b
2 changed files with 5 additions and 2 deletions

View file

@ -17,4 +17,5 @@ declare module 'composeverter' {
export function migrateFromV2xToV3x(content: string, configuration?: Configuration = null): string;
export function getDockerComposeSchemaWithoutFormats(): object;
export function yamlParse(content: string): object;
export function yamlCheck(content: string): object;
}

View file

@ -1,5 +1,5 @@
import { type MaybeRef, get } from '@vueuse/core';
import { yamlParse } from 'composeverter';
import { yamlCheck } from 'composeverter';
import yaml from 'yaml';
export { formatYaml };
@ -13,7 +13,9 @@ function formatYaml({
sortKeys?: MaybeRef<boolean>
indentSize?: MaybeRef<number>
}) {
const parsedYaml = yamlParse(get(rawYaml));
const rawYamlString = get(rawYaml);
yamlCheck(rawYamlString);
const parsedYaml = yaml.parse(rawYamlString, { intAsBigInt: true });
const formattedYAML = yaml.stringify(parsedYaml, {
sortMapEntries: get(sortKeys),