]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/core-utils/logs/logs.ts
Merge branch 'release/3.2.0' into develop
[github/Chocobozzz/PeerTube.git] / shared / core-utils / logs / logs.ts
1 import { stat } from 'fs-extra'
2
3 async function mtimeSortFilesDesc (files: string[], basePath: string) {
4 const promises = []
5 const out: { file: string, mtime: number }[] = []
6
7 for (const file of files) {
8 const p = stat(basePath + '/' + file)
9 .then(stats => {
10 if (stats.isFile()) out.push({ file, mtime: stats.mtime.getTime() })
11 })
12
13 promises.push(p)
14 }
15
16 await Promise.all(promises)
17
18 out.sort((a, b) => b.mtime - a.mtime)
19
20 return out
21 }
22
23 export {
24 mtimeSortFilesDesc
25 }