Skip to content

Commit

Permalink
fix(cli): handle silent flag at the top level promise
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Aug 10, 2020
1 parent 4ee89e0 commit 08534ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/ts/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import {parseFlags} from './util'
const flags = parseFlags(process.argv.slice(2))

run(flags).catch(reason => {
console.error(reason)
!flags.silent && console.error(reason)
process.exit(+reason.status || 1)
})
6 changes: 3 additions & 3 deletions src/main/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ const npmAuditFix: TCallback = ({temp, flags}) =>
invoke('npm', [
'audit', 'fix', '--package-lock-only',
...formatFlags(flags, 'verbose', 'loglevel', 'only', 'force', 'audit-level', 'silent'),
], temp)
], temp, flags.silent)

/**
* Generate yarn.lock by package-lock.json data.
* @param {TContext} cxt
* @return {void}
*/
const yarnImport: TCallback = ({temp, flags}) => {
invoke('yarn', ['import', ...formatFlags(flags, 'verbose', 'silent')], temp)
invoke('yarn', ['import', ...formatFlags(flags, 'verbose', 'silent')], temp, flags.silent)
fs.copyFileSync(join(temp, 'yarn.lock'), 'yarn.lock')
}

Expand All @@ -74,7 +74,7 @@ const yarnImport: TCallback = ({temp, flags}) => {
* @return {void}
*/
const yarnInstall: TCallback = ({cwd, flags}) =>
invoke('yarn', [...formatFlags(flags, 'verbose', 'silent')], cwd)
invoke('yarn', [...formatFlags(flags, 'verbose', 'silent')], cwd, flags.silent)

/**
* Clean up temporaries.
Expand Down
4 changes: 2 additions & 2 deletions src/test/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ describe('yarn-audit-fix', () => {
let reason = {error: new Error('foobar')} as any
// @ts-ignore
cp.spawnSync.mockImplementation(() => reason)
await expect(run()).rejects.toBe(reason)
await expect(run({silent: true})).rejects.toBe(reason)

reason = {status: 1}
// @ts-ignore
cp.spawnSync.mockImplementation(() => reason)
await expect(run()).rejects.toBe(reason)
await expect(run({silent: true})).rejects.toBe(reason)
})
})

Expand Down

0 comments on commit 08534ed

Please sign in to comment.