Skip to content

Commit

Permalink
feat: print invocation details to stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jul 13, 2020
1 parent 515a928 commit f92b18a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/ts/invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import cp from 'child_process'
export const invoke = (cmd: string, args: string[], cwd: string) => {
const result = cp.spawnSync(cmd, args, {cwd})

console.log('invoke', cmd, ...args)

if (result.error || result.status !== 0) {
throw result.error || result.stderr.toString('utf-8')
}

console.log(result.stdout.toString('utf-8'))
}
2 changes: 1 addition & 1 deletion src/test/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('yarn-audit-fix', () => {
// @ts-ignore
synp.yarnToNpm.mockImplementation(() => '{}')
// @ts-ignore
cp.spawnSync.mockImplementation(() => ({status: 0}))
cp.spawnSync.mockImplementation(() => ({status: 0, stdout: 'foobar'}))
})
afterAll(jest.clearAllMocks)

Expand Down

0 comments on commit f92b18a

Please sign in to comment.