From 1e7298a23c3c2d09810f6e1a54ead8a449d7fd7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iiro=20J=C3=A4ppinen?= Date: Wed, 25 Mar 2020 17:20:29 +0200 Subject: [PATCH] fix: do not return string from runAll, add info symbol to "No staged files found." message --- lib/runAll.js | 3 +-- test/__snapshots__/runAll.spec.js.snap | 4 ++-- test/runAll.spec.js | 3 +-- test/runAll.unmocked.spec.js | 3 +-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/runAll.js b/lib/runAll.js index 66951c0c1..fe5fd1a4e 100644 --- a/lib/runAll.js +++ b/lib/runAll.js @@ -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 }) diff --git a/test/__snapshots__/runAll.spec.js.snap b/test/__snapshots__/runAll.spec.js.snap index 2140eb414..c0f1bb48d 100644 --- a/test/__snapshots__/runAll.spec.js.snap +++ b/test/__snapshots__/runAll.spec.js.snap @@ -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`] = ` @@ -85,5 +85,5 @@ LOG { exports[`runAll should use an injected logger 1`] = ` " -LOG No staged files found." +LOG i No staged files found." `; diff --git a/test/runAll.spec.js b/test/runAll.spec.js index f19b7562a..ffdf0387a 100644 --- a/test/runAll.spec.js +++ b/test/runAll.spec.js @@ -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 () => { diff --git a/test/runAll.unmocked.spec.js b/test/runAll.unmocked.spec.js index f4ec637de..f4e94fdc5 100644 --- a/test/runAll.unmocked.spec.js +++ b/test/runAll.unmocked.spec.js @@ -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 () => {