Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
})