mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-05-08 15:15:02 -04:00
Using existing yaml package instead of js-yaml
This commit is contained in:
parent
5f92d640c9
commit
1e8dc931a9
4 changed files with 7 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
|||
import { type MaybeRef, get } from '@vueuse/core';
|
||||
|
||||
import yaml from 'js-yaml';
|
||||
import yaml from 'yaml';
|
||||
|
||||
export { formatYaml };
|
||||
|
||||
|
@ -13,10 +13,10 @@ function formatYaml({
|
|||
sortKeys?: MaybeRef<boolean>
|
||||
indentSize?: MaybeRef<number>
|
||||
}) {
|
||||
const parsedYaml = yaml.load(get(rawYaml));
|
||||
const parsedYaml = yaml.parse(get(rawYaml));
|
||||
|
||||
const formattedYAML = yaml.dump(parsedYaml, {
|
||||
sortKeys: get(sortKeys),
|
||||
const formattedYAML = yaml.stringify(parsedYaml, {
|
||||
sortMapEntries: get(sortKeys),
|
||||
indent: get(indentSize),
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import yaml from 'js-yaml';
|
||||
import yaml from 'yaml';
|
||||
import { useStorage } from '@vueuse/core';
|
||||
import { formatYaml } from './yaml-models';
|
||||
import { withDefaultOnError } from '@/utils/defaults';
|
||||
|
@ -18,7 +18,7 @@ const rawYamlValidation = useValidation({
|
|||
source: rawYaml,
|
||||
rules: [
|
||||
{
|
||||
validator: v => v === '' || yaml.load(v),
|
||||
validator: v => v === '' || yaml.parse(v),
|
||||
message: 'Provided YAML is not valid.',
|
||||
},
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue