Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
philipparndt committed Jan 19, 2022
1 parent b54f0bf commit 388060e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
5 changes: 2 additions & 3 deletions app/lib/logger.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { createLogger, log } from "./logger"
import { log } from "./logger"
import { Writable } from "stream"
import * as winston from "winston"
import * as Transport from "winston-transport"


export class TestLogger {
output = ""
transports: Transport[]
Expand All @@ -21,7 +20,7 @@ export class TestLogger {

close = () => {
log.clear()
for (let transport of this.transports) {
for (const transport of this.transports) {
log.add(transport)
}
}
Expand Down
1 change: 0 additions & 1 deletion app/lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ export const createLogger = (transport: Transport = new winston.transports.Conso
}

export const log = createLogger()

1 change: 0 additions & 1 deletion app/lib/put/put-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ describe("PUT handler", () => {

expect(messages.length).toBe(0)
expect(logger.output).toMatch(/\d+\d+\d+\d+-\d+\d+-\d+\d+T.* ERROR invalid message Unexpected token i in JSON at position 0.*/)

})

test("Turn on", async () => {
Expand Down
27 changes: 14 additions & 13 deletions app/lib/put/put-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,23 @@ export const putMessage = async (resource: HueIdentifiable, message: Buffer) =>
if (isLight(resource)) {
// only supported for light messages at the moment
try {
const lightMsg = JSON.parse(message.toString()) as LightMessage | LightEffectMessage
if (isEffectMessage(lightMsg)) {
await applyEffect(resource, lightMsg)
}
else {
const newResource = toLight(resource, lightMsg)

// resource will be updated by the Hue SSE API
try {
await putResource(newResource)
const lightMsg = JSON.parse(message.toString()) as LightMessage | LightEffectMessage
if (isEffectMessage(lightMsg)) {
await applyEffect(resource, lightMsg)
}
catch (e) {
log.error(e)
else {
const newResource = toLight(resource, lightMsg)

// resource will be updated by the Hue SSE API
try {
await putResource(newResource)
}
catch (e) {
log.error(e)
}
}
}
} catch (e) {
catch (e) {
log.error("invalid message", e)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"coverage": "jest --coverage",
"start": "tsc && node dist/index.js",
"build": "tsc",
"lint": "eslint lib/** --ext .ts",
"lint": "eslint lib/** --ext .ts --fix",
"generate-test-stubs": "node dist/lib/test-stub-generator.js"
},
"keywords": [],
Expand Down

0 comments on commit 388060e

Please sign in to comment.