UNPKG

907 BJavaScriptView Raw
1#!/usr/bin/env node
2
3/* eslint-disable no-console */
4const Redis = require('ioredis').Cluster;
5const assert = require('assert');
6const conf = require('../lib/config');
7
8const config = conf.get('/', { env: process.env.NODE_ENV });
9const redisConfig = config.redis;
10const { updatePassword } = require('../lib/actions/updatePassword');
11
12const username = process.argv[2];
13const password = process.argv[3];
14assert(username, 'must provide id as argv[2]');
15assert(password, 'must provide password of token as argv[3]');
16
17
18const redis = new Redis(redisConfig.hosts, ({ ...redisConfig.options, lazyConnect: true }));
19
20// connection options
21redis
22 .connect()
23 .bind({ redis })
24 .return([username, password])
25 .spread(updatePassword)
26 .then(() => {
27 console.info('\nSet password for %s to "%s"\n', username, password);
28 return redis.disconnect();
29 })
30 .catch((err) => setImmediate(() => { throw err; }));