@cenk1cenk2/oclif-common 3.1.0-beta.3 → 3.1.0-beta.4

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.
Files changed (2) hide show
  1. package/dist/index.js +24 -23
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -661,7 +661,6 @@ var ConfigService = class {
661
661
  },
662
662
  ...extras
663
663
  ];
664
- this.logger.trace("Added to search for environment variables: %o", variable);
665
664
  return variable;
666
665
  } else {
667
666
  return iter(value, location);
@@ -672,20 +671,23 @@ var ConfigService = class {
672
671
  return data.flatMap((d) => d);
673
672
  }, "iter");
674
673
  const parsed = await iter(env);
674
+ const cb = /* @__PURE__ */ __name(async (variable, data) => {
675
+ if (variable.parser) {
676
+ try {
677
+ variable = await this.parser.parse(variable.parser, data);
678
+ } catch (e) {
679
+ this.logger.trace("Can not parse environment environment variable for config: %s -> %s with %s", variable.key.join("."), variable.env, variable.parser);
680
+ throw e;
681
+ }
682
+ }
683
+ return import_object_path_immutable.default.update(config, variable.key, () => {
684
+ this.logger.trace("Overwriting config with environment variable: %s -> %s", variable.key.join("."), variable.env);
685
+ return variable;
686
+ });
687
+ }, "cb");
675
688
  await Promise.all(
676
689
  parsed.map(async (variable) => {
677
- let data = process.env[variable.env];
678
- if (!data) {
679
- return;
680
- }
681
- if (variable.parser) {
682
- try {
683
- data = await this.parser.parse(variable.parser, data);
684
- } catch (e) {
685
- this.logger.trace("Can not parse environment variable for config: %s -> %s with %s", variable.key.join("."), variable.env, variable.parser);
686
- throw e;
687
- }
688
- }
690
+ let data;
689
691
  if (variable.key.includes("__element" /* ELEMENT */)) {
690
692
  const timeout = 6e4;
691
693
  const startedAt = Date.now();
@@ -694,24 +696,23 @@ var ConfigService = class {
694
696
  throw new Error(`Timed-out in ${timeout}ms while looking for element environment variables.`);
695
697
  }
696
698
  const clone = JSON.parse(JSON.stringify(variable));
699
+ clone.env = clone.env.replace("${i}" /* ELEMENT_REPLACER */, i.toString());
697
700
  this.logger.trace("Looking for environment variable element: %o", clone);
698
- data = process.env[clone.env.replace("${i}" /* ELEMENT_REPLACER */, i.toString())];
701
+ data = process.env[clone.env];
699
702
  if (!data) {
700
703
  this.logger.trace("No more variable available: %s -> %d", variable.env, i);
701
704
  break;
702
705
  }
703
706
  clone.key[clone.key.findIndex((value) => value === "__element" /* ELEMENT */)] = i;
704
- config = import_object_path_immutable.default.update(config, clone.key, () => {
705
- this.logger.trace("Overwriting config with element environment variable: %s -> %s", clone.key.join("."), variable.env);
706
- return data;
707
- });
707
+ config = await cb(clone, data);
708
708
  }
709
- } else {
710
- config = import_object_path_immutable.default.update(config, variable.key, () => {
711
- this.logger.trace("Overwriting config with environment variable: %s -> %s", variable.key.join("."), variable.env);
712
- return data;
713
- });
709
+ return;
710
+ }
711
+ data = process.env[variable.env];
712
+ if (!data) {
713
+ return;
714
714
  }
715
+ config = await cb(variable, data);
715
716
  })
716
717
  );
717
718
  return config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cenk1cenk2/oclif-common",
3
- "version": "3.1.0-beta.3",
3
+ "version": "3.1.0-beta.4",
4
4
  "description": "Oclif common package for oclif2 projects.",
5
5
  "repository": "https://gitlab.kilic.dev/libraries/oclif-tools",
6
6
  "author": {