-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (28 loc) · 887 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
const alfy = require('alfy')
const fs = require('fs')
const os = require('os')
const path = require('path')
const connections = (() => {
let connections = alfy.cache.get('connections')
if (connections) {
return connections
}
const jsonPath = path.join(os.homedir(), 'Library/Application Support/Tinkerun/app/connections.json')
const data = JSON.parse(fs.readFileSync(jsonPath))
delete data['quick_connection']
connections = Object.values(data)
alfy.cache.set('connections', connections, {maxAge: 5000})
return connections
})()
let items = connections
if (alfy.input) {
items = alfy.inputMatches(connections, 'name')
}
alfy.output(items.map(element => ({
title: element.name,
subtitle: element.command,
arg: element.id,
icon: {
path: element.is_over_ssh ? 'assets/cloud.png' : 'assets/desktop.png',
}
})))