Skip to content

Commit

Permalink
readme and a deno format
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinta365 committed Mar 6, 2024
1 parent 5773f1c commit b745af9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ const apiKey = getEnv("API_KEY");
console.log(`Home directory: ${getEnv("HOME")}`);
```

Get variable or throw error if not set.

```javascript
// Will throw an UndefinedEnvironmentError error if variable is unset.
const dbUri = requireEnv("DB_URI");
```

Simple set example.

```javascript
Expand Down
4 changes: 2 additions & 2 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@cross/env",
"version": "0.2.1",
"version": "0.2.2",
"exports": "./mod.ts",

"tasks": {
"test": "deno test --allow-env ./tests/deno.ts",
"test": "deno test --allow-env --allow-read ./tests/deno.ts",
"publish": "deno publish --config jsr.jsonc",
"publish-dry": "deno publish --dry-run --config jsr.jsonc"
},
Expand Down
8 changes: 7 additions & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
* retrieving environment variables across Deno, Bun and Node.js
*/

import { EnvOptions, UndefinedEnvironmentError, UnsupportedEnvironmentError, ValidationError, ValidatorFunction } from "./lib/helpers.ts";
import {
EnvOptions,
UndefinedEnvironmentError,
UnsupportedEnvironmentError,
ValidationError,
ValidatorFunction,
} from "./lib/helpers.ts";
import { deepMerge } from "@cross/deepmerge";
import { getCurrentRuntime } from "@cross/runtime";
import { loadEnvFile } from "./lib/filehandler.ts";
Expand Down
2 changes: 1 addition & 1 deletion tests/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Deno.test({
Deno.test({
name: "requireEnv() throws for nonexistant keys",
fn: () => {
assertThrows(() => requireEnv("TEST_KEY_NONEXISTANT"), "TEST_KEY_NONEXISTANT not defined in environment.")
assertThrows(() => requireEnv("TEST_KEY_NONEXISTANT"), "TEST_KEY_NONEXISTANT not defined in environment.");
},
});

Expand Down

0 comments on commit b745af9

Please sign in to comment.