mirror of
https://github.com/engineer-man/piston.git
synced 2025-04-20 20:16:26 +02:00
cli: code cleanup
This commit is contained in:
parent
e57e56037c
commit
d1b41e3c2f
3 changed files with 19 additions and 14 deletions
|
@ -17,11 +17,13 @@ exports.handler = async function(argv){
|
|||
const api = new PistonEngine(argv['piston-url']);
|
||||
|
||||
const repos = await api.list_repos();
|
||||
|
||||
const repos_obj = await Promise.all(repos.repos.map(({slug}) => api.get_repo(slug)));
|
||||
|
||||
const repo_pkgs = await Promise.all(repos_obj.map(
|
||||
async repo => ({
|
||||
repo: repo,
|
||||
packages: await repo.list_packages().catch(x=>[])
|
||||
packages: await repo.list_packages().catch(_=>[])
|
||||
})
|
||||
))
|
||||
|
||||
|
|
|
@ -17,11 +17,14 @@ exports.handler = async function(argv){
|
|||
const api = new PistonEngine(argv['piston-url']);
|
||||
|
||||
const repos = await api.list_repos();
|
||||
|
||||
const repos_obj = await Promise.all(repos.repos.map(({slug}) => api.get_repo(slug)));
|
||||
const packages = await repos_obj.reduce(async (a, c) => [
|
||||
...await a,
|
||||
...await c.list_packages().catch(x=>{console.log(x); return []})
|
||||
], []);
|
||||
|
||||
const packages = await repos_obj.reduce(async (accumulator, repo) => [
|
||||
...await accumulator,
|
||||
...await repo.list_packages()
|
||||
.catch(x=>{console.log(x); return []})
|
||||
], []); // Loops over repos, listing packages and flattening them into a single array
|
||||
|
||||
const pkg_msg = packages
|
||||
.map(msg_format.color)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue