@cenk1cenk2/oclif-common 6.2.0 → 6.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -183,7 +183,8 @@ declare class ParserService {
183
183
  private moduleRef;
184
184
  private fs;
185
185
  private readonly logger;
186
- parsers: ClassType<GenericParser>[];
186
+ private readonly parsers;
187
+ private readonly instances;
187
188
  constructor(moduleRef: ModuleRef, fs: FileSystemService, logger: LoggerService);
188
189
  byFt(file: string): GenericParser;
189
190
  fetch<T extends GenericParser>(Parser: ClassType<T>): T;
package/dist/index.js CHANGED
@@ -612,10 +612,12 @@ var ParserService = (_a6 = class {
612
612
  __publicField(this, "fs");
613
613
  __publicField(this, "logger");
614
614
  __publicField(this, "parsers");
615
+ __publicField(this, "instances");
615
616
  this.moduleRef = moduleRef;
616
617
  this.fs = fs2;
617
618
  this.logger = logger;
618
619
  this.parsers = [];
620
+ this.instances = [];
619
621
  this.logger.setup(this.constructor.name);
620
622
  }
621
623
  byFt(file) {
@@ -627,10 +629,15 @@ var ParserService = (_a6 = class {
627
629
  return this.fetch(Parser);
628
630
  }
629
631
  fetch(Parser) {
630
- return this.moduleRef.get(Parser);
632
+ const parser = this.instances.find((instance) => instance instanceof Parser);
633
+ if (!parser) {
634
+ throw new Error(`Specified parser has not been initiated: ${Parser.name}`);
635
+ }
636
+ return parser;
631
637
  }
632
638
  async inject(Parser) {
633
639
  const parser = await this.moduleRef.create(Parser);
640
+ this.instances.push(parser);
634
641
  return parser;
635
642
  }
636
643
  async register(...parsers) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cenk1cenk2/oclif-common",
3
- "version": "6.2.0",
3
+ "version": "6.2.1",
4
4
  "description": "Oclif common package for oclif2 projects.",
5
5
  "repository": "https://gitlab.kilic.dev/libraries/oclif-tools",
6
6
  "type": "module",