Skip to content

Commit

Permalink
feat: export all inners
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jun 6, 2021
1 parent 5fdad15 commit 4794e2d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,17 @@ All mentioned above CLI options can be replaced with corresponding env variables
* `YAF_ONLY=prod``--only=prod`

### JS API
**yarn-audit-fix** is a naive and optimistic workaround, so it exposes all of its inners to give anybody a chance to tweak up and find a better steps combination.
Typedoc: [https://antongolub.github.io/yarn-audit-fix/modules/](https://antongolub.github.io/yarn-audit-fix/modules/)

```ts
import { run } from 'yarn-audit-fix'

await run({
flow: 'patch',
verbose: true
})
```

## Troubleshooting
### yarn-audit-fix version x.x.x is out of date
Expand Down
6 changes: 4 additions & 2 deletions src/main/ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './stages'
export { getFlow } from './flows'
export * from './ifaces'
export * from './lockfile'
export * from './runner'
export * from './flows'
export * from './stages'
export * from './util'
2 changes: 1 addition & 1 deletion src/main/ts/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk'
import { join } from 'path'

import { getFlow } from './flows'
import { TCallback, TContext, TFlags, TFlow, TStage } from './ifaces'
import { TCallback, TContext, TFlags, TStage } from './ifaces'
import { getTemp, normalizeFlags, readJson } from './util'

/**
Expand Down
8 changes: 4 additions & 4 deletions src/main/ts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import cp, { StdioOptions } from 'child_process'
import crypto from 'crypto'
import findCacheDir from 'find-cache-dir'
import { sync as findUp } from 'find-up'
import fs, { ensureDirSync, readFileSync, SymlinkType } from 'fs-extra'
import { ensureDirSync, readFileSync, SymlinkType } from 'fs-extra'
import { GlobbyOptions, sync as glob } from 'globby'
import { reduce } from 'lodash'
import { join, resolve } from 'path'
Expand Down Expand Up @@ -107,13 +107,13 @@ export const getSymlinkType = (type?: string): SymlinkType =>
// https://github.com/facebook/jest/issues/2993
export const getYarn = (): string => (isWindows() ? 'yarn.cmd' : 'yarn')

export const getClosestNpm = (cmd: string): string =>
export const getClosestBin = (cmd: string): string =>
String(
findUp(
(dir) => {
const ref = resolve(dir, 'node_modules', '.bin', cmd)

return fs.existsSync(ref) ? ref : undefined
return findUp.exists(ref) ? ref : undefined
},
{
cwd: String(pkgDir(__dirname)),
Expand All @@ -129,7 +129,7 @@ export const getNpm = (npmPath = 'local', isWin = isWindows()): string => {
}

if (npmPath === 'local') {
return getClosestNpm(cmd)
return getClosestBin(cmd)
}

return npmPath
Expand Down

0 comments on commit 4794e2d

Please sign in to comment.