From e40fe2da8f3b3602ab48445517ad95cb6f249685 Mon Sep 17 00:00:00 2001 From: TeoDev1611 Date: Fri, 19 Aug 2022 21:09:29 -0500 Subject: [PATCH] feat: improve the set status --- mod.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mod.ts b/mod.ts index 43fc4f8..8fc5f28 100644 --- a/mod.ts +++ b/mod.ts @@ -1,4 +1,3 @@ -import { parse as parseJSONC } from 'encoding/jsonc.ts'; import { basename, extname, join } from 'path/mod.ts'; import { BenoSetTypes, BenoTypes } from './src/parsers/types.d.ts'; import { benoMagicReader, benoOneFile } from './src/parsers/reader.ts'; @@ -9,10 +8,12 @@ interface BenoCfgFunctions { config(path?: string, env?: string): void; get(key: string): unknown | undefined; content(): Record[] | undefined; - set(filename: string, object: BenoSetTypes): void; + set(filename: string, object: BenoSetTypes): boolean; } export class Beno implements BenoCfgFunctions { + version = '0.1.0'; + constructor(private props: BenoTypes) { this.props.path = join(Deno.cwd(), 'config'); this.props.envPath = join(Deno.cwd(), '.env'); @@ -63,7 +64,7 @@ export class Beno implements BenoCfgFunctions { return new Validate((target ?? {})[key]); } - set(filename: string, object: BenoSetTypes): void { + set(filename: string, object: BenoSetTypes): boolean { const content = this.content(); if (content == undefined) { @@ -101,6 +102,7 @@ export class Beno implements BenoCfgFunctions { `Beno ERROR: Is not possible write the file error.\n${e}`, ); } + return true; } } else { throw new Error( @@ -108,5 +110,7 @@ export class Beno implements BenoCfgFunctions { ); } }); + + return false; } }