4 const userService = require('gitter-web-users');
5 const shutdown = require('shutdown');
7 require('../../server/event-listeners').install();
9 const opts = require('yargs')
12 description: 'username to reserve e.g trevorah',
15 .option('unreserve', {
18 description: 'unreserve usersername'
21 .alias('help', 'h').argv;
26 return userService.unreserveUsername(opts.username);
29 return userService.reserveUsername(opts.username);
32 var action = opts.unreserve
33 ? 'unreserved and people are free to register that username'
34 : 'reserved and can no longer be registered';
35 console.log(opts.username, 'has been', action);
37 // wait 5 seconds to allow for asynchronous `event-listeners` to finish
38 // https://github.com/troupe/gitter-webapp/issues/580#issuecomment-147445395
39 // https://gitlab.com/gitterHQ/webapp/merge_requests/1605#note_222861592
41 console.log(`Waiting 5 seconds to allow for the asynchronous \`event-listeners\` to finish...`);
42 return new Promise(resolve => setTimeout(resolve, 5000));
44 .catch(function(err) {
45 console.error(err.stack);
48 shutdown.shutdownGracefully();