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

fix: return deno env object #432

Merged
merged 4 commits into from Feb 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yaml
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
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
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')
})