diff --git a/README.md b/README.md index 38a00cb3..4cdd10af 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/main/ts/index.ts b/src/main/ts/index.ts index 72b2cca8..3f4772a8 100644 --- a/src/main/ts/index.ts +++ b/src/main/ts/index.ts @@ -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' diff --git a/src/main/ts/runner.ts b/src/main/ts/runner.ts index b79c8543..3641fd2a 100644 --- a/src/main/ts/runner.ts +++ b/src/main/ts/runner.ts @@ -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' /** diff --git a/src/main/ts/util.ts b/src/main/ts/util.ts index b4439ea8..c9082744 100644 --- a/src/main/ts/util.ts +++ b/src/main/ts/util.ts @@ -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' @@ -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)), @@ -129,7 +129,7 @@ export const getNpm = (npmPath = 'local', isWin = isWindows()): string => { } if (npmPath === 'local') { - return getClosestNpm(cmd) + return getClosestBin(cmd) } return npmPath