MCPcopy
hub / github.com/vitest-dev/vitest / inputFilePattern

Function inputFilePattern

packages/vitest/src/node/stdin.ts:214–246  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

212 }
213
214 async function inputFilePattern() {
215 off()
216
217 const watchFilter = new WatchFilter(
218 'Input filename pattern',
219 stdin,
220 stdout,
221 )
222
223 const filter = await watchFilter.filter(async (str: string) => {
224 const specifications = await ctx.globTestSpecifications([str])
225
226 return specifications
227 .map(specification => relative(ctx.config.root, specification.moduleId))
228 .filter((file, index, all) => all.indexOf(file) === index)
229 })
230
231 on()
232
233 if (typeof filter === 'undefined') {
234 return
235 }
236
237 latestFilename = filter?.trim() || ''
238 const lastResults = watchFilter.getLastResults()
239
240 await ctx.changeFilenamePattern(
241 latestFilename,
242 filter && lastResults.length
243 ? lastResults.map(i => resolve(ctx.config.root, i))
244 : undefined,
245 )
246 }
247
248 let rl: readline.Interface | undefined
249 function on() {

Callers 1

_keypressHandlerFunction · 0.85

Calls 10

filterMethod · 0.95
getLastResultsMethod · 0.95
changeFilenamePatternMethod · 0.80
offFunction · 0.70
onFunction · 0.70
filterMethod · 0.65
relativeFunction · 0.50
resolveFunction · 0.50
indexOfMethod · 0.45

Tested by

no test coverage detected