Skip to content

Commit

Permalink
Fixed error reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
usmanyunusov committed Feb 15, 2022
1 parent 8e8c907 commit b3f822f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export default async function (opts = { ...defaultOptions, ...opts }) {
} else {
await runner.run()
}
} catch (error) {
for (const error of toArray(error)) {
} catch (errors) {
for (const error of toArray(errors)) {
reporter.error(error)
}

throw error
throw errors
}
}
6 changes: 0 additions & 6 deletions lib/spinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ class Spinner {
return this
}

collups() {
if (this.spins.length) {
this.spins = []
}
}

create(text) {
let spin = new Spinner(this.spinner, text, this.level + 1)
this.spins.push(spin)
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export async function createTasksRunner({
throw new TaskRunnerError(errors.join('\n\n'))
}

spinner.collups()
spinner.spins = []
} catch (err) {
throw err
}
Expand Down
22 changes: 22 additions & 0 deletions test/tasks-runner.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,26 @@ test('should run handle error', async () => {
}
})

test('should run handle success', async () => {
const { createTasksRunner } = await esmock('../lib/tasks-runner.js', {
'../lib/executor.js': {
executor: async () => Promise.resolve('Run done'),
},
})

let runner = await createTasksRunner({
repoPath: 'test',
files: ['a.js', '../../b.css'],
config: { '*.js': ['prettier --write', 'prettier --write'], '*.css': () => 'prettier --write' },
stream: stdout,
})

const spinner = new MultiSpinner({ stream: stdout })

await runner.run(spinner)
is(stdout.out, '\x1B[?25l\x1B[33m\\\x1B[39m *.js\x1B[2m - 1 file\x1B[22m')

spinner.stop()
})

test.run()

0 comments on commit b3f822f

Please sign in to comment.