-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (31 loc) · 799 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
const alfy = require('alfy');
const got = require('got');
const input = alfy.input.toLowerCase();
const fileUrl = 'https://github.com/github/gitignore/blob/master/';
function filter(tree) {
return tree
.filter(x => {
filename = x.path.replace(/Global\//, '')
return filename.endsWith('.gitignore') &&
filename.toLowerCase().indexOf(input) >= 0
})
.map(x => {
filename = x.path.replace(/Global\//, '')
return {
title: filename,
arg: fileUrl + x.path
}
})
.sort();
}
const url = 'https://alfred-workflows-62254.firebaseio.com/gi.json'
alfy.fetch(url, {
maxAge: 86400000, // 24 hours
})
.then(items => {
const output = filter(items);
alfy.output(output);
})
.catch(error => {
alfy.log(error);
});