Skip to content

Commit

Permalink
fix: return deno env object (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
johanholmerin authored Feb 27, 2022
1 parent 91b569e commit b00eb87
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ jobs:
deno-version: v1.x
- run: |
deno --version
deno test --allow-read test/deno/yargs-test.ts
deno test --allow-read --allow-env test/deno/yargs-test.ts
env:
MY_PREFIX_MY_KEY: "my value"
browser:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { Arguments, ArgsInput, Parser, Options, DetailedArguments } from '.
const parser = new YargsParser({
cwd: Deno.cwd,
env: () => {
Deno.env.toObject()
return Deno.env.toObject()
},
format: (str: string, arg: string) => { return str.replace('%s', arg) },
normalize: path.posix.normalize,
Expand Down
5 changes: 5 additions & 0 deletions test/deno/yargs-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,8 @@ Deno.test('it detects strings that could be parsed as numbers', () => {
assertEquals(parser.looksLikeNumber('0100'), false)
assertEquals(parser.looksLikeNumber('apple'), false)
})

Deno.test('should load values from environment variables', () => {
const argv = parser([], { envPrefix: 'MY_PREFIX_' })
assertEquals(argv.myKey, 'my value')
})

0 comments on commit b00eb87

Please sign in to comment.