core: fix lang preferences when changed lang list

This commit is contained in:
undefined committed 2021-03-10 22:02:44 +08:00
1 parent 391eb96b22
commit e7780c56bb
7 files changed
+29 -40

No files matched your search

+8
View File
@@ -1,4 +1,5 @@
import { inspect } from 'util';
import * as yaml from 'js-yaml';
import * as judge from './judge';
import { ValidationError } from '../error';
import * as check from '../check';
@@ -28,6 +29,13 @@ function set(key: string, value: any) {
if (!Number.isSafeInteger(+value)) throw new ValidationError(key);
return +value;
}
if (s.subType === 'yaml') {
try {
yaml.load(value);
} catch (e) {
throw new ValidationError(key);
}
}
return value;
}
return undefined;