]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/core-utils/logs/logs.ts
Translated using Weblate (Russian)
[github/Chocobozzz/PeerTube.git] / shared / core-utils / logs / logs.ts
CommitLineData
cda03765
C
1import { stat } from 'fs-extra'
2
3async 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
23export {
24 mtimeSortFilesDesc
25}