Merge branch 'hotfix/21.56.9' into master
[gitter.git] / scripts / utils / list-group-admins.js
blobb8fbcbb2c762b368c54dedbf86a54b2c72bcd41e
1 #!/usr/bin/env node
2 'use strict';
4 const shutdown = require('shutdown');
6 const groupService = require('gitter-web-groups');
7 const findGroupAdminUsers = require('./lib/find-group-admin-users');
9 const opts = require('yargs')
10   .option('uri', {
11     alias: 'u',
12     required: true,
13     description: 'URI of group to remove',
14     string: true
15   })
16   .help('help')
17   .alias('help', 'h').argv;
19 groupService
20   .findByUri(opts.uri)
21   .then(group => {
22     if (!group) {
23       throw new Error(`Group with URI ${group.uri} does not exist`);
24     }
26     console.log(`Processing ${group.uri}`);
27     return findGroupAdminUsers(group);
28   })
29   .then(function() {
30     shutdown.shutdownGracefully();
31   })
32   .catch(function(err) {
33     console.error(err);
34     console.error(err.stack);
35     process.exit(1);
36     shutdown.shutdownGracefully(1);
37   });