Skip to content

Commit

Permalink
feat: improve the set status
Browse files Browse the repository at this point in the history
  • Loading branch information
TeoDev1611 committed Aug 20, 2022
1 parent c5a8762 commit e40fe2d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -9,10 +8,12 @@ interface BenoCfgFunctions {
config(path?: string, env?: string): void;
get(key: string): unknown | undefined;
content(): Record<string, unknown>[] | 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');
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -101,12 +102,15 @@ export class Beno implements BenoCfgFunctions {
`Beno ERROR: Is not possible write the file error.\n${e}`,
);
}
return true;
}
} else {
throw new Error(
`Beno ERROR: Not valid internal path please report this on github maybe a Bug`,
);
}
});

return false;
}
}

0 comments on commit e40fe2d

Please sign in to comment.