(
target: string,
options: {
ignore?: string
formatter: Formatter
ruleset?: Ruleset
},
onFinished: (result: {
targetFileCount: number
targetHintFileCount: number
targetHintCount: number
arrTargetMessages: Array<{
file: string
messages: Hint[]
time: number
}>
}) => void
)
| 248 | |
| 249 | // hint all files |
| 250 | function hintAllFiles( |
| 251 | target: string, |
| 252 | options: { |
| 253 | ignore?: string |
| 254 | formatter: Formatter |
| 255 | ruleset?: Ruleset |
| 256 | }, |
| 257 | onFinished: (result: { |
| 258 | targetFileCount: number |
| 259 | targetHintFileCount: number |
| 260 | targetHintCount: number |
| 261 | arrTargetMessages: Array<{ |
| 262 | file: string |
| 263 | messages: Hint[] |
| 264 | time: number |
| 265 | }> |
| 266 | }) => void |
| 267 | ) { |
| 268 | const globInfo = getGlobInfo(target) |
| 269 | globInfo.ignore = options.ignore |
| 270 | |
| 271 | const formatter = options.formatter |
| 272 | |
| 273 | // hint result |
| 274 | let targetFileCount = 0 |
| 275 | let targetHintFileCount = 0 |
| 276 | let targetHintCount = 0 |
| 277 | const arrTargetMessages: Array<{ |
| 278 | file: string |
| 279 | messages: Hint[] |
| 280 | time: number |
| 281 | }> = [] |
| 282 | |
| 283 | // init ruleset |
| 284 | let ruleset = options.ruleset |
| 285 | if (ruleset === undefined) { |
| 286 | ruleset = getConfig(cliOptions.config, globInfo.base, formatter) |
| 287 | } |
| 288 | |
| 289 | // hint queue |
| 290 | const hintQueue = asyncQueue<string>((filepath, next) => { |
| 291 | const startTime = new Date().getTime() |
| 292 | |
| 293 | if (filepath === 'stdin') { |
| 294 | hintStdin(ruleset, hintNext) |
| 295 | } else if (/^https?:\/\//.test(filepath)) { |
| 296 | hintUrl(filepath, ruleset, hintNext) |
| 297 | } else { |
| 298 | const messages = hintFile(filepath, ruleset) |
| 299 | hintNext(messages) |
| 300 | } |
| 301 | |
| 302 | function hintNext(messages: Hint[]) { |
| 303 | const spendTime = new Date().getTime() - startTime |
| 304 | const hintCount = messages.length |
| 305 | if (hintCount > 0) { |
| 306 | formatter.emit('file', { |
| 307 | file: filepath, |
no test coverage detected