Skip to content

Commit

Permalink
actually use the --files config
Browse files Browse the repository at this point in the history
This was an oversight in the v18 rewrite.

Fix: #922
  • Loading branch information
isaacs committed Sep 27, 2023
1 parent 385f0a0 commit f01a6df
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/run/src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export const list = async (
) => {
const saveList: Set<string> = new Set(await readSave(config))

if (args.length === 0) args = config.get('files') || []

const ignore = [alwaysExcludePattern]
if (values.exclude) ignore.push(...values.exclude)

Expand Down
21 changes: 20 additions & 1 deletion src/run/test/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ t.test('list some test files', async t => {

const sortedLog = () =>
logs
.args()[0][0]
.args()[0]?.[0]
.trim()
.split('\n')
.sort((a: string, b: string) => a.localeCompare(b, 'en'))
Expand Down Expand Up @@ -115,6 +115,25 @@ t.test('list some test files', async t => {
])
})

t.test('config files', async t => {
const orig = mainConfig.config.get
t.capture(
mainConfig.config,
'get',
(k: Parameters<typeof mainConfig.config.get>[0]) => {
if (k === 'files') return ['src/*.spec.js', 'test/*.*js']
return orig.call(mainConfig.config, k)
}
)
await list([], mainConfig.config)
t.strictSame(sortedLog(), [
'src/index.spec.js',
'src/test.spec.js',
'test/foo.cjs',
'test/foo.mjs',
])
})

t.test('specific files, noent, and stdin', async t => {
await list(
['src/test.spec.js', '/dev/stdin', '-', 'enoent not exists'],
Expand Down

0 comments on commit f01a6df

Please sign in to comment.