1234567891011121314151617181920212223242526272829303132333435363738 |
- type Status =
- | 'found'
- | 'unused'
- | 'missing'
- | 'malformed'
- | 'timeout'
- | 'fetching_failed'
- | 'other'
- | null
- | undefined;
- function getStatusWeight(status: Status) {
- switch (status) {
- case null:
- case undefined:
- case 'unused':
- return 0;
- case 'found':
- return 1;
- default:
- return 2;
- }
- }
- function combineStatus(debugStatus: Status, unwindStatus: Status): Status {
- const debugWeight = getStatusWeight(debugStatus);
- const unwindWeight = getStatusWeight(unwindStatus);
- const combined = debugWeight >= unwindWeight ? debugStatus : unwindStatus;
- return combined || 'unused';
- }
- function getFileName(path: string) {
- const directorySeparator = /^([a-z]:\\|\\\\)/i.test(path) ? '\\' : '/';
- return path.split(directorySeparator).pop();
- }
- export {combineStatus, getFileName};
|