Skip to content

Commit

Permalink
fix: do not return string from runAll, add info symbol to "No staged …
Browse files Browse the repository at this point in the history
…files found." message
  • Loading branch information
iiroj committed Mar 30, 2020
1 parent c386e4c commit 1e7298a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions lib/runAll.js
Expand Up @@ -106,8 +106,7 @@ const runAll = async (

// If there are no files avoid executing any lint-staged logic
if (files.length === 0) {
logger.log('No staged files found.')
return 'No tasks to run.'
return logger.log(`${symbols.info} No staged files found.`)
}

const stagedFileChunks = chunkFiles({ files, gitDir, maxArgLength, relative })
Expand Down
4 changes: 2 additions & 2 deletions test/__snapshots__/runAll.spec.js.snap
Expand Up @@ -18,7 +18,7 @@ LOG Cleaning up... [completed]"

exports[`runAll should resolve the promise with no files 1`] = `
"
LOG No staged files found."
LOG i No staged files found."
`;

exports[`runAll should skip applying unstaged modifications if there are errors during linting 1`] = `
Expand Down Expand Up @@ -85,5 +85,5 @@ LOG {

exports[`runAll should use an injected logger 1`] = `
"
LOG No staged files found."
LOG i No staged files found."
`;
3 changes: 1 addition & 2 deletions test/runAll.spec.js
Expand Up @@ -33,8 +33,7 @@ describe('runAll', () => {
})

it('should resolve the promise with no tasks', async () => {
const res = await runAll({ config: {} })
expect(res).toEqual('No tasks to run.')
await expect(runAll({ config: {} })).resolves
})

it('should resolve the promise with no files', async () => {
Expand Down
3 changes: 1 addition & 2 deletions test/runAll.unmocked.spec.js
Expand Up @@ -115,8 +115,7 @@ describe('runAll', () => {
})

it('should exit early with no staged files', async () => {
const status = await runAll({ config: { '*.js': 'echo success' }, cwd })
expect(status).toEqual('No tasks to run.')
expect(() => runAll({ config: { '*.js': 'echo success' }, cwd })).resolves
})

it('Should commit entire staged file when no errors from linter', async () => {
Expand Down

0 comments on commit 1e7298a

Please sign in to comment.