Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding config #1

Merged
merged 39 commits into from
Apr 2, 2021
Merged

adding config #1

merged 39 commits into from
Apr 2, 2021

Conversation

trilom
Copy link
Contributor

@trilom trilom commented Apr 1, 2021

config

  • adding config
    Simple
import { EnvConfig, StringConfig } from "trailmix/config/mod.ts";

Deno.env.set("DEFAULT_TEST1", "val1"); // set example env var in DEFAULT namespace
// slurp up env vars
console.log(EnvConfig.parseEnv()); // should have { test1: "val1" }
// something more complex
Deno.env.set("DEFAULT_CONSOLE_LEVEL", "DEBUG"); // set log level in DEFAULT namespace
console.log(EnvConfig.parseEnv()); // should have { test1: "val1", console: { level: "DEBUG" } }
// this is good for cmd line arguments (--consoleLevel DEBUG)
console.log(StringConfig.parseEnv({ test1: "val1", consoleLevel: "DEBUG" })); // should have same as above

Complex

import { Config, EnvConfig, StringConfig } from "trailmix/config/mod.ts";

// lets use our own namespace with a config file
const c = await new Config({
  namespace: "TRAILMIX",
  prefix: "trailmixString.config",
}).init();
// inside trailmixString.config.ts/tsx
export default {
  consoleFormat: "json",
};
console.log(new StringConfig(c).parseLog()); // will give a log config with {console: { format: "json" } }
// now lets take into account env vars
Deno.env.set("TRAILMIX_CONSOLE_FORMAT", "console");
console.log(new EnvConfig(c).parseLog()); // will give a log config with {console: { format: "console" } }

@codecov
Copy link

codecov bot commented Apr 1, 2021

Codecov Report

Merging #1 (068155f) into master (46719d1) will decrease coverage by 13.17%.
The diff coverage is 85.08%.

Impacted file tree graph

@@             Coverage Diff              @@
##            master       #1       +/-   ##
============================================
- Coverage   100.00%   86.82%   -13.18%     
============================================
  Files            2       13       +11     
  Lines          164      668      +504     
  Branches        13       58       +45     
============================================
+ Hits           164      580      +416     
- Misses           0       87       +87     
- Partials         0        1        +1     
Flag Coverage Δ
color 86.82% <85.08%> (?)
common 86.82% <85.08%> (?)
config 86.82% <85.08%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/color/enum.ts 100.00% <ø> (ø)
src/common/table.ts 65.92% <65.92%> (ø)
src/config/Config.ts 75.36% <75.36%> (ø)
src/common/file.ts 81.81% <81.81%> (ø)
src/config/EnvConfig.ts 87.50% <87.50%> (ø)
src/config/StringConfig.ts 88.33% <88.33%> (ø)
src/color/Color.ts 100.00% <100.00%> (ø)
src/color/mod.ts 100.00% <100.00%> (ø)
src/common/array.ts 100.00% <100.00%> (ø)
src/common/enum.ts 100.00% <100.00%> (ø)
... and 15 more

@trilom trilom merged commit 13ad956 into master Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant