Created
February 20, 2021 15:13
-
-
Save azu/9916ab182c1e27c2c0edbb4345a1d5dd to your computer and use it in GitHub Desktop.
gh + node → alfred workflow: GitHub Project Script Filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/usr/local/bin/gh api graphql -F owner='owner' -F name='name' -f query=' | |
query ($name: String!, $owner: String!) { | |
repository(owner: $owner, name: $name) { | |
projects(first: 20) { | |
edges { | |
node { | |
name | |
url | |
} | |
} | |
} | |
} | |
} | |
' | ~/.volta/bin/node -e ' | |
var stdin = ""; | |
process.stdin.resume(); | |
process.stdin.setEncoding("utf8"); | |
process.stdin.on("data", function (chunk) { stdin += chunk }); | |
process.stdin.on("end", function () { | |
const items = JSON.parse(stdin).data.repository.projects.edges.map(({node}) => { | |
return { | |
uid: node.url, | |
title: node.name, | |
subtitle: node.url, | |
arg: node.url, | |
autocomplete: node.name, | |
} | |
}); | |
console.log(JSON.stringify({ items })); | |
}); | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment