From 8927368424c8ab5277972586a03b639a6e44ae08 Mon Sep 17 00:00:00 2001 From: Dom Harrington Date: Sun, 30 Sep 2018 19:21:34 -0700 Subject: [PATCH] Prettier --- cli.js | 2 +- config/default.js | 2 +- lib/login.js | 23 +++++++++++++---------- lib/open.js | 4 ++-- test/login.test.js | 8 ++++---- test/open.test.js | 6 +++--- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/cli.js b/cli.js index 7c0ba0224..af2815cf4 100644 --- a/cli.js +++ b/cli.js @@ -38,7 +38,7 @@ module.exports = function(cmd, args, opts = {}) { [command, subcommand] = cmd.split(':'); } - const optsWithStoredKey = Object.assign({}, { key: configStore.get('apiKey') }, opts) + const optsWithStoredKey = Object.assign({}, { key: configStore.get('apiKey') }, opts); try { return load(opts.help ? 'help' : command, subcommand).run({ args, opts: optsWithStoredKey }); diff --git a/config/default.js b/config/default.js index 838bb24e8..8a2e85652 100644 --- a/config/default.js +++ b/config/default.js @@ -2,5 +2,5 @@ module.exports = { // eslint-disable-next-line global-require cli: require('../package.json').name, host: 'https://dash.readme.io', - hub: 'https://{project}.readme.io' + hub: 'https://{project}.readme.io', }; diff --git a/lib/login.js b/lib/login.js index 6d0f40324..f22aa9788 100644 --- a/lib/login.js +++ b/lib/login.js @@ -19,7 +19,7 @@ function getCredentials() { return resolve({ email, password }); }); - }) + }); }); } @@ -48,12 +48,15 @@ exports.run = async function({ opts }) { return Promise.reject(err); } - return request.post(`${config.host}/api/v1/login`, { - json: { email, password, project }, - }).then((res) => { - configStore.set('apiKey', res.apiKey); - configStore.set('email', email); - configStore.set('project', project); - return `Successfully logged in as ${email.green} in the ${project.blue} project`; - }).catch(badRequest); -} + return request + .post(`${config.host}/api/v1/login`, { + json: { email, password, project }, + }) + .then(res => { + configStore.set('apiKey', res.apiKey); + configStore.set('email', email); + configStore.set('project', project); + return `Successfully logged in as ${email.green} in the ${project.blue} project`; + }) + .catch(badRequest); +}; diff --git a/lib/open.js b/lib/open.js index f4e602d27..c647c6ba4 100644 --- a/lib/open.js +++ b/lib/open.js @@ -7,7 +7,7 @@ exports.weight = 1; const configStore = require('../lib/configstore'); -exports.run = function ({ opts }) { +exports.run = function({ opts }) { const project = configStore.get('project'); if (!project) { @@ -17,4 +17,4 @@ exports.run = function ({ opts }) { return (opts.mockOpen || open)(config.hub.replace('{project}', project), { wait: false, }).then(() => null); -} +}; diff --git a/test/login.test.js b/test/login.test.js index 90927b19b..b6749dc55 100644 --- a/test/login.test.js +++ b/test/login.test.js @@ -9,13 +9,13 @@ describe('login command', () => { beforeAll(() => nock.disableNetConnect()); afterAll(() => nock.cleanAll()); - it('should error if no project provided', (done) => + it('should error if no project provided', done => login([], {}).catch(err => { assert.equal(err.message, 'No project subdomain provided. Please use --project'); return done(); })); - it('should error if email is invalid', (done) => + it('should error if email is invalid', done => login([], { project: 'subdomain', email: 'this-is-not-an-email' }).catch(err => { assert.equal(err.message, 'You must provide a valid email address.'); return done(); @@ -40,7 +40,7 @@ describe('login command', () => { }); }); - it('should error if invalid credentials are given', (done) => { + it('should error if invalid credentials are given', done => { const email = 'dom@readme.io'; const password = '123456'; const project = 'subdomain'; @@ -52,7 +52,7 @@ describe('login command', () => { error: 'Bad Request', }); - return login([], { email, password, project }).catch((err) => { + return login([], { email, password, project }).catch(err => { mock.done(); assert.equal(err.error, 'Bad Request'); assert.equal(err.description, 'Invalid email/password'); diff --git a/test/open.test.js b/test/open.test.js index dd01cc840..b1776d4b0 100644 --- a/test/open.test.js +++ b/test/open.test.js @@ -6,16 +6,16 @@ const configStore = require('../lib/configstore'); const open = require('../cli').bind(null, 'open'); describe('open command', () => { - it('should error if no project provided', (done) => { + it('should error if no project provided', done => { configStore.delete('project'); open([], {}).catch(err => { assert.equal(err.message, `Please login using ${config.cli} login`); return done(); - }) + }); }); - it('should open the project', (done) => { + it('should open the project', done => { configStore.set('project', 'subdomain'); function mockOpen(url) {