Skip to content

Commit

Permalink
feat: provide env directives
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Mar 24, 2021
1 parent 7eb3034 commit 6a61668
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ success Already up-to-date.
|`--registry` | Custom registry url |
|`--skip-flags-check` | Disable CLI flags verification |

### ENV
All mentioned above CLI directives can be replaced with corresponding env variables with leading **YAF** prefix. For example:
* `YAF_FORCE` equals `--force`
* `YAF_ONLY=prod``--only=prod`

## Troubleshooting
### enoent: no such file or directory
In some cases **npm audit fix** makes `node_modules` to become inconsistent. This is expected. **yarn** and **npm** organize the directory space slightly differently.
Expand Down
6 changes: 3 additions & 3 deletions src/test/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const strMatching = (temp: string, ending: string) =>

describe('yarn-audit-fix', () => {
beforeAll(() => {
process.env.YAF_SKIP_CLI_CHECK = 'true'
process.env.YAF_SKIP_FLAGS_CHECK = 'true'
})
beforeEach(() => {
// @ts-ignore
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('yarn-audit-fix', () => {
})
afterEach(jest.clearAllMocks)
afterAll(() => {
delete process.env.YAF_SKIP_CLI_CHECK
delete process.env.YAF_SKIP_FLAGS_CHECK
jest.resetAllMocks()
})

Expand Down Expand Up @@ -150,7 +150,7 @@ describe('yarn-audit-fix', () => {
foo: 'bar',
'package-lock-only': true,
registry: registryUrl,
'skip-cli-check': true,
'skip-flags-check': true,
})
checkFlow()
})
Expand Down
4 changes: 2 additions & 2 deletions src/test/ts/stages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('stages', () => {
expect(() => checkFlags({ ...ctx, flags: { foo: 'bar'}} )).toThrowError('Unsupported flag: foo')
})

it('suppresses error if `skip-cli-check` passed', () => {
expect(checkFlags({ ...ctx, flags: { foo: 'bar', 'skip-cli-check': true}} )).toBeUndefined()
it('suppresses error if `skip-flags-check` passed', () => {
expect(checkFlags({ ...ctx, flags: { foo: 'bar', 'skip-flags-check': true}} )).toBeUndefined()
})

it('returns undefined if flags are valid', () => {
Expand Down

0 comments on commit 6a61668

Please sign in to comment.