-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (34 loc) · 864 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict'
const alfy = require('alfy')
const alfredNotifier = require('alfred-notifier')
const trending = require('trending-github')
let [language, period] = alfy.input.split(' ')
if (!period) {
period = 'daily'
}
alfredNotifier()
if (alfy.cache.get('repos')) {
alfy.output(alfy.cache.get('repos'))
} else {
trending(period, language).then(repos => {
const output = repos.map(repo => ({
title: `${repo.author}/${repo.name}`,
subtitle: repo.description,
arg: repo.href,
mods: {
alt: {
subtitle: `Language: ${repo.language}, stars: ${repo.stars}, fork: ${repo.forks}`
}
},
text: {
copy: repo.href,
largetype: repo.description
},
quicklookurl: repo.href
}))
alfy.cache.set('repos', output, {
maxAge: 600000
})
alfy.output(output)
})
}