Skip to content

Instantly share code, notes, and snippets.

@azu
Created February 20, 2021 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azu/9916ab182c1e27c2c0edbb4345a1d5dd to your computer and use it in GitHub Desktop.
Save azu/9916ab182c1e27c2c0edbb4345a1d5dd to your computer and use it in GitHub Desktop.
gh + node → alfred workflow: GitHub Project Script Filter
/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