fix: replace deprecated utility fns
This commit is contained in:
parent
01f639f078
commit
06726e91fc
|
@ -1,4 +1,4 @@
|
|||
import { mustCoalesce } from '@apextoaster/js-utils';
|
||||
import { mustDefault } from '@apextoaster/js-utils';
|
||||
import { DEFAULT_SCHEMA, Schema } from 'js-yaml';
|
||||
|
||||
import { envType } from './type/Env';
|
||||
|
@ -17,7 +17,7 @@ export interface SchemaOptions {
|
|||
* @public
|
||||
*/
|
||||
export function createSchema(options: SchemaOptions): Schema {
|
||||
const base = mustCoalesce(options.base, DEFAULT_SCHEMA);
|
||||
const base = mustDefault(options.base, DEFAULT_SCHEMA);
|
||||
|
||||
return base.extend([
|
||||
envType,
|
||||
|
@ -43,7 +43,7 @@ export interface IncludeSchemaOptions {
|
|||
* @deprecated use `createSchema` unless the include type is needed, since it requires a number of callbacks
|
||||
*/
|
||||
export function createIncludeSchema(options: Readonly<IncludeSchemaOptions>): Schema {
|
||||
const base = mustCoalesce(options.base, DEFAULT_SCHEMA);
|
||||
const base = mustDefault(options.base, DEFAULT_SCHEMA);
|
||||
const { includeType, setSchema } = createInclude({
|
||||
...options.include,
|
||||
schema: base,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { InvalidArgumentError, mustCoalesce, NotFoundError, Optional } from '@apextoaster/js-utils';
|
||||
import { InvalidArgumentError, Maybe, mustDefault, NotFoundError } from '@apextoaster/js-utils';
|
||||
import { DEFAULT_SCHEMA, load, Schema, Type as YamlType } from 'js-yaml';
|
||||
|
||||
export type ReaderEncoding = 'ascii' | 'utf-8';
|
||||
|
@ -18,7 +18,7 @@ export interface IncludeOptions {
|
|||
join: (...path: Array<string>) => string;
|
||||
read: IncludeReader;
|
||||
resolve: (path: string) => string;
|
||||
schema: Optional<Schema>;
|
||||
schema: Maybe<Schema>;
|
||||
}
|
||||
|
||||
export interface IncludeResult {
|
||||
|
@ -40,7 +40,7 @@ const ERROR_INCLUDE_PARSE = 'error loading included file';
|
|||
*/
|
||||
export function createInclude(options: Readonly<IncludeOptions>): IncludeResult {
|
||||
const mutableOptions = {
|
||||
schema: mustCoalesce(options.schema, DEFAULT_SCHEMA),
|
||||
schema: mustDefault(options.schema, DEFAULT_SCHEMA),
|
||||
};
|
||||
|
||||
const includeType = new YamlType('!include', {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { InvalidArgumentError, isNil } from '@apextoaster/js-utils';
|
||||
import { InvalidArgumentError, isNone } from '@apextoaster/js-utils';
|
||||
import { Type as YamlType } from 'js-yaml';
|
||||
|
||||
export const REGEXP_REGEXP = /^\/(.+)\/([gimsuy]*)$/;
|
||||
|
@ -13,7 +13,7 @@ export const regexpType = new YamlType('!regexp', {
|
|||
},
|
||||
construct(value: string): RegExp {
|
||||
const match = REGEXP_REGEXP.exec(value);
|
||||
if (isNil(match)) {
|
||||
if (isNone(match)) {
|
||||
throw new InvalidArgumentError('invalid regexp');
|
||||
}
|
||||
const [/* input */, expr, flags] = Array.from(match);
|
||||
|
|
Loading…
Reference in New Issue