diff --git a/src/runAll.js b/src/runAll.js index 06ac2aa68..e956e7f25 100644 --- a/src/runAll.js +++ b/src/runAll.js @@ -54,8 +54,7 @@ module.exports = function runAll(config) { return `No staged files match ${task.pattern}` } return false - }, - hasStagedFiles: () => task.fileList.length > 0 + } })) const listrBaseOptions = { @@ -63,12 +62,16 @@ module.exports = function runAll(config) { renderer } - let hasStagedTaskFiles = false + // If all of the configured "linters" should be skipped + // avoid executing any "stashing changes..." logic + let isSkippingAllLinters = true tasks.forEach(task => { - hasStagedTaskFiles = hasStagedTaskFiles || task.hasStagedFiles() + if (!task.skip()) { + isSkippingAllLinters = false + } }) - if (hasStagedTaskFiles) { + if (!isSkippingAllLinters) { // Do not terminate main Listr process on SIGINT process.on('SIGINT', () => {}) diff --git a/test/runAll.spec.js b/test/runAll.spec.js index f1bf96103..c4f7d1b98 100644 --- a/test/runAll.spec.js +++ b/test/runAll.spec.js @@ -162,7 +162,7 @@ describe('runAll', () => { } }) - it.only('should skip stashing changes if no lint-staged files are changed', async () => { + it('should skip stashing changes if no lint-staged files are changed', async () => { expect.assertions(4) hasPartiallyStagedFiles.mockImplementationOnce(() => Promise.resolve(true)) sgfMock.mockImplementationOnce((params, callback) => {