Skip to content

Commit

Permalink
Spaces inside curly braces
Browse files Browse the repository at this point in the history
  • Loading branch information
timdp committed Sep 2, 2016
1 parent f230b8d commit 18ca765
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import gulp from 'gulp'
import loadPlugins from 'gulp-load-plugins'
import {Instrumenter} from 'isparta'
import { Instrumenter } from 'isparta'
import del from 'del'
import seq from 'run-sequence'
import yargs from 'yargs'
Expand Down Expand Up @@ -28,12 +28,12 @@ gulp.task('transpile', () => {
gulp.task('lint', () => {
return gulp.src('{src,test}/**/*.js')
.pipe($.standard())
.pipe($.standard.reporter('default', {breakOnError: false}))
.pipe($.standard.reporter('default', { breakOnError: false }))
})

gulp.task('pre-coverage', () => {
return gulp.src('src/**/*.js')
.pipe($.istanbul({instrumenter: Instrumenter}))
.pipe($.istanbul({ instrumenter: Instrumenter }))
.pipe($.istanbul.hookRequire())
})

Expand All @@ -44,7 +44,7 @@ gulp.task('coverage', ['pre-coverage'], () => {
grep: argv.grep
}))
.pipe($.istanbul.writeReports())
.pipe($.istanbul.enforceThresholds({thresholds: COVERAGE_THRESHOLDS}))
.pipe($.istanbul.enforceThresholds({ thresholds: COVERAGE_THRESHOLDS }))
})

gulp.task('test', (cb) => seq('lint', 'coverage', cb))
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

import {Transport} from 'winston'
import { Transport } from 'winston'
import CloudWatchClient from './lib/cloudwatch-client'
import LogItem from './lib/log-item'
import Relay from './lib/relay'
Expand Down
20 changes: 10 additions & 10 deletions src/lib/cloudwatch-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import CloudWatchEventFormatter from './cloudwatch-event-formatter'

export default class CloudWatchClient {
constructor (logGroupName, logStreamName, options) {
debug('constructor', {logGroupName, logStreamName, options})
debug('constructor', { logGroupName, logStreamName, options })
this._logGroupName = logGroupName
this._logStreamName = logStreamName
this._options = defaults(options, {
Expand All @@ -28,11 +28,11 @@ export default class CloudWatchClient {
}

submit (batch) {
debug('submit', {batch})
debug('submit', { batch })
return this._initialize()
.then(() => this._getSequenceToken())
.then((sequenceToken) => this._putLogEvents(batch, sequenceToken))
.then(({nextSequenceToken}) => this._storeSequenceToken(nextSequenceToken))
.then(({ nextSequenceToken }) => this._storeSequenceToken(nextSequenceToken))
}

_initialize () {
Expand Down Expand Up @@ -73,7 +73,7 @@ export default class CloudWatchClient {
}

_putLogEvents (batch, sequenceToken) {
debug('putLogEvents', {batch, sequenceToken})
debug('putLogEvents', { batch, sequenceToken })
const params = {
logGroupName: this._logGroupName,
logStreamName: this._logStreamName,
Expand All @@ -94,27 +94,27 @@ export default class CloudWatchClient {
_fetchAndStoreSequenceToken () {
debug('fetchSequenceToken')
return this._findLogStream()
.then(({uploadSequenceToken}) => this._storeSequenceToken(uploadSequenceToken))
.then(({ uploadSequenceToken }) => this._storeSequenceToken(uploadSequenceToken))
}

_storeSequenceToken (sequenceToken) {
debug('storeSequenceToken', {sequenceToken})
debug('storeSequenceToken', { sequenceToken })
const date = +new Date()
this._sequenceTokenInfo = {sequenceToken, date}
this._sequenceTokenInfo = { sequenceToken, date }
return sequenceToken
}

_findLogStream (nextToken) {
debug('findLogStream', {nextToken})
debug('findLogStream', { nextToken })
const params = {
logGroupName: this._logGroupName,
logStreamNamePrefix: this._logStreamName,
nextToken
}
return this._client.describeLogStreams(params).promise()
.then(({logStreams, nextToken}) => {
.then(({ logStreams, nextToken }) => {
const match = find(logStreams,
({logStreamName}) => (logStreamName === this._logStreamName))
({ logStreamName }) => (logStreamName === this._logStreamName))
if (match) {
return match
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ export default class Queue {
}

push (item) {
debug('push', {item})
debug('push', { item })
this._contents.push(item)
}

head (num) {
debug('head', {num})
debug('head', { num })
return this._contents.slice(0, num)
}

remove (num) {
debug('remove', {num})
debug('remove', { num })
this._contents.splice(0, num)
}
}
30 changes: 15 additions & 15 deletions test/unit/cloudwatch-client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ const logStreamName = 'testStream'
let tokens = 0
let streams = 0

const withPromise = (res) => ({promise: () => res})
const withPromise = (res) => ({ promise: () => res })

const mapRequest = (stub, includeExpected, token, nextToken) => {
const suffixes = [++streams, ++streams, includeExpected ? '' : ++streams]
const res = Promise.resolve({
logStreams: suffixes.map((suf) => ({logStreamName: logStreamName + suf})),
logStreams: suffixes.map((suf) => ({ logStreamName: logStreamName + suf })),
nextToken
})
if (token) {
stub.withArgs(sinon.match({nextToken: token}))
stub.withArgs(sinon.match({ nextToken: token }))
.returns(withPromise(res))
} else {
stub.returns(withPromise(res))
Expand Down Expand Up @@ -59,7 +59,7 @@ const createClient = (options) => {
const client = new CloudWatchClient(logGroupName, logStreamName,
options.clientOptions)
sinon.stub(client._client, 'putLogEvents')
.returns(withPromise(Promise.resolve({nextSequenceToken: 'token42'})))
.returns(withPromise(Promise.resolve({ nextSequenceToken: 'token42' })))
sinon.stub(client._client, 'createLogGroup')
.returns(withPromise(options.groupErrorCode
? Promise.reject(createErrorWithCode(options.groupErrorCode))
Expand All @@ -76,7 +76,7 @@ const createClient = (options) => {
const createBatch = (size) => {
const batch = []
for (let i = 0; i < size; ++i) {
batch.push(new LogItem(+new Date(), 'info', 'Test', {foo: 'bar'}))
batch.push(new LogItem(+new Date(), 'info', 'Test', { foo: 'bar' }))
}
return batch
}
Expand Down Expand Up @@ -127,7 +127,7 @@ describe('CloudWatchClient', () => {
describe('#options.maxSequenceTokenAge', () => {
it('caches the sequence token', () => {
const client = createClient({
clientOptions: {maxSequenceTokenAge: 1000}
clientOptions: { maxSequenceTokenAge: 1000 }
})
return expect(
client.submit(createBatch(1))
Expand All @@ -143,7 +143,7 @@ describe('CloudWatchClient', () => {
return `CUSTOM__${JSON.stringify(item)}`
})
const client = createClient({
clientOptions: {formatLog}
clientOptions: { formatLog }
})
const batch = createBatch(1)
return expect(
Expand All @@ -162,7 +162,7 @@ describe('CloudWatchClient', () => {
}
})
const client = createClient({
clientOptions: {formatLogItem}
clientOptions: { formatLogItem }
})
const batch = createBatch(1)
return expect(
Expand All @@ -182,7 +182,7 @@ describe('CloudWatchClient', () => {
}
})
const client = createClient({
clientOptions: {formatLog, formatLogItem}
clientOptions: { formatLog, formatLogItem }
})
const batch = createBatch(1)
return expect(
Expand All @@ -195,7 +195,7 @@ describe('CloudWatchClient', () => {
describe('#options.createLogGroup', () => {
it('creates the log group', () => {
const client = createClient({
clientOptions: {createLogGroup: true}
clientOptions: { createLogGroup: true }
})
const batch = createBatch(1)
return expect(
Expand All @@ -206,7 +206,7 @@ describe('CloudWatchClient', () => {

it('does not throw if the log group already exists', () => {
const client = createClient({
clientOptions: {createLogGroup: true},
clientOptions: { createLogGroup: true },
groupErrorCode: 'ResourceAlreadyExistsException'
})
const batch = createBatch(1)
Expand All @@ -217,7 +217,7 @@ describe('CloudWatchClient', () => {

it('throws if another error occurs', () => {
const client = createClient({
clientOptions: {createLogGroup: true},
clientOptions: { createLogGroup: true },
groupErrorCode: 'UnicornDoesNotExistException'
})
const batch = createBatch(1)
Expand All @@ -230,7 +230,7 @@ describe('CloudWatchClient', () => {
describe('#options.createLogStream', () => {
it('creates the log stream', () => {
const client = createClient({
clientOptions: {createLogStream: true}
clientOptions: { createLogStream: true }
})
const batch = createBatch(1)
return expect(
Expand All @@ -241,7 +241,7 @@ describe('CloudWatchClient', () => {

it('does not throw if the log stream already exists', () => {
const client = createClient({
clientOptions: {createLogStream: true},
clientOptions: { createLogStream: true },
streamErrorCode: 'ResourceAlreadyExistsException'
})
const batch = createBatch(1)
Expand All @@ -252,7 +252,7 @@ describe('CloudWatchClient', () => {

it('throws if another error occurs', () => {
const client = createClient({
clientOptions: {createLogStream: true},
clientOptions: { createLogStream: true },
streamErrorCode: 'UnicornDoesNotExistException'
})
const batch = createBatch(1)
Expand Down

0 comments on commit 18ca765

Please sign in to comment.