From 6d349ec415e3009a2bf762457ddb92f83d566731 Mon Sep 17 00:00:00 2001 From: Dom Harrington Date: Tue, 8 May 2018 14:51:37 -0700 Subject: [PATCH] Prettier --- cli.js | 2 +- lib/docs.js | 11 +++++++++-- rdme.js | 2 +- test/cli.test.js | 20 ++++++++++---------- test/docs.test.js | 15 ++++++++++++--- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/cli.js b/cli.js index 76b3d3ec6..7599b0fe8 100644 --- a/cli.js +++ b/cli.js @@ -20,7 +20,7 @@ module.exports = function(cmd, args, opts = {}) { try { const command = load(opts.help ? 'help' : cmd); return command.run({ args, opts }); - } catch(e) { + } catch (e) { return Promise.reject(e); } }; diff --git a/lib/docs.js b/lib/docs.js index ade9709a2..70ae3bf29 100644 --- a/lib/docs.js +++ b/lib/docs.js @@ -62,7 +62,11 @@ exports.run = function({ args, opts }) { if (hash === existingDoc.lastUpdatedHash) return undefined; return request .put(`${config.host}/api/v1/docs/${slug}`, { - json: Object.assign(existingDoc, { body: file.content, ...file.data, lastUpdatedHash: hash }), + json: Object.assign(existingDoc, { + body: file.content, + ...file.data, + lastUpdatedHash: hash, + }), ...options, }) .catch(validationErrors); @@ -74,7 +78,10 @@ exports.run = function({ args, opts }) { const matter = frontMatter(file); // Stripping the markdown extension from the filename const slug = filename.replace(path.extname(filename), ''); - const hash = crypto.createHash('sha1').update(file).digest('hex'); + const hash = crypto + .createHash('sha1') + .update(file) + .digest('hex'); return request .get(`${config.host}/api/v1/docs/${slug}`, { diff --git a/rdme.js b/rdme.js index f76a99f2f..51a9f59b7 100755 --- a/rdme.js +++ b/rdme.js @@ -10,7 +10,7 @@ const parseArgs = require('minimist')(process.argv.slice(2), { // // Allows --help, -h, -H h: 'help', H: 'help', - } + }, }); require('./cli')(parseArgs._[0], parseArgs._.slice(1), parseArgs) diff --git a/test/cli.test.js b/test/cli.test.js index 9a65c1887..4ac46d0a4 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -7,7 +7,7 @@ const { version } = require('../package.json'); describe('cli', () => { it('command not found', done => cli('notARealCommand').catch(e => { - assert.equal(e.message.includes('Command not found'), true) + assert.equal(e.message.includes('Command not found'), true); return done(); })); @@ -17,17 +17,17 @@ describe('cli', () => { // This is necessary because we use --version for other commands like `docs` it('should only return version if no command', () => - cli('no-such-command', [], minimist(['--version'])).then(() => { - throw new Error('Should not get here'); - }).catch(() => { - // This can be ignored as it's just going to be - // a command not found error - })); + cli('no-such-command', [], minimist(['--version'])) + .then(() => { + throw new Error('Should not get here'); + }) + .catch(() => { + // This can be ignored as it's just going to be + // a command not found error + })); }); describe('--help', () => { - it('should print help and not error', () => - cli('', [], minimist(['--help'])) - ); + it('should print help and not error', () => cli('', [], minimist(['--help']))); }); }); diff --git a/test/docs.test.js b/test/docs.test.js index 191f42ac6..0f1c60394 100644 --- a/test/docs.test.js +++ b/test/docs.test.js @@ -39,7 +39,10 @@ describe('docs command', () => { const doc = frontMatter( fs.readFileSync(path.join(__dirname, `./fixtures/existing-docs/${slug}.md`)), ); - const hash = crypto.createHash('sha1').update(fs.readFileSync(path.join(__dirname, `./fixtures/existing-docs/${slug}.md`))).digest('hex'); + const hash = crypto + .createHash('sha1') + .update(fs.readFileSync(path.join(__dirname, `./fixtures/existing-docs/${slug}.md`))) + .digest('hex'); const getMock = nock(config.host, { reqheaders: { @@ -73,7 +76,10 @@ describe('docs command', () => { it('should not send requests for docs that have not changed', () => { const slug = 'simple-doc'; - const hash = crypto.createHash('sha1').update(fs.readFileSync(path.join(__dirname, `./fixtures/existing-docs/${slug}.md`))).digest('hex'); + const hash = crypto + .createHash('sha1') + .update(fs.readFileSync(path.join(__dirname, `./fixtures/existing-docs/${slug}.md`))) + .digest('hex'); const getMock = nock(config.host, { reqheaders: { @@ -96,7 +102,10 @@ describe('docs command', () => { const doc = frontMatter( fs.readFileSync(path.join(__dirname, `./fixtures/new-docs/${slug}.md`)), ); - const hash = crypto.createHash('sha1').update(fs.readFileSync(path.join(__dirname, `./fixtures/new-docs/${slug}.md`))).digest('hex'); + const hash = crypto + .createHash('sha1') + .update(fs.readFileSync(path.join(__dirname, `./fixtures/new-docs/${slug}.md`))) + .digest('hex'); const getMock = nock(config.host, { reqheaders: {