Skip to content

Commit

Permalink
fix: include all files when using --config <path>
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed May 31, 2022
1 parent 753ef72 commit 641d1c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 3 additions & 5 deletions lib/groupFilesByConfig.js
Expand Up @@ -2,11 +2,9 @@ import path from 'path'

import debug from 'debug'

import { ConfigObjectSymbol } from './searchConfigs.js'

const debugLog = debug('lint-staged:groupFilesByConfig')

export const groupFilesByConfig = async ({ configs, files }) => {
export const groupFilesByConfig = async ({ configs, files, singleConfigMode }) => {
debugLog('Grouping %d files by %d configurations', files.length, Object.keys(configs).length)

const filesSet = new Set(files)
Expand All @@ -16,8 +14,8 @@ export const groupFilesByConfig = async ({ configs, files }) => {
for (const filepath of Reflect.ownKeys(configs)) {
const config = configs[filepath]

/** When passed an explicit config object via the Node.js API, skip logic */
if (filepath === ConfigObjectSymbol) {
/** When passed an explicit config object via the Node.js API‚ or an explicit path, skip logic */
if (singleConfigMode) {
filesByConfig[filepath] = { config, files }
break
}
Expand Down
6 changes: 5 additions & 1 deletion lib/runAll.js
Expand Up @@ -133,7 +133,11 @@ export const runAll = async (
throw createError(ctx, ConfigNotFoundError)
}

const filesByConfig = await groupFilesByConfig({ configs: foundConfigs, files })
const filesByConfig = await groupFilesByConfig({
configs: foundConfigs,
files,
singleConfigMode: configObject || configPath !== undefined,
})

const hasMultipleConfigs = numberOfConfigs > 1

Expand Down

0 comments on commit 641d1c2

Please sign in to comment.