Skip to content

Commit

Permalink
Added jshint, added jshint to gulp build and updated comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarvesh Chitko committed Feb 26, 2019
1 parent b7fff78 commit a794e6e
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 16 deletions.
9 changes: 9 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"esnext":true,
"node" : true,
"asi":true,
"predef" : [
"require"
],
"indent" : 2
}
2 changes: 1 addition & 1 deletion dist/index-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ const UDPInput = require("./UDPInput.class-min")
const TCPInput = require("./TCPInput.class-min")
const WebSocketInput = require("./WebSocketInput.class-min")
const HTTPInput = require("./HTTPInput.class-min")

module.exports =
/**
* @class LogstashTransport
* @extends Transport
* @desc The main class that adds the Logstash capabilities to Winston
* @throws UnsupportedInputError
* @throws InvalidParametersError
*/
module.exports =
class LogstashTransport extends winston.Transport {
/**
*
* @param {Object} options - The Configuration object
* @param {String} options.name - The name of the transport
* @param {String} options.input - The input that you want to use
Expand All @@ -29,16 +31,16 @@ class LogstashTransport extends winston.Transport {
this.host = options.host
this.port = options.port
if(this.input && this.host && this.port){
if(this.input=="udp"){
if(this.input==="udp"){
this.input = new UDPInput(options)
}
else if(this.input=="tcp"){
else if(this.input==="tcp"){
this.input = new TCPInput(options)
}
else if(this.input=="websocket"){
else if(this.input==="websocket"){
this.input = new WebSocketInput(options)
}
else if(this.input=="http"){
else if(this.input==="http"){
this.input = new HTTPInput(options)
}
else {
Expand All @@ -57,7 +59,7 @@ class LogstashTransport extends winston.Transport {
log(info,callback) {
setImmediate(()=>{
this.input.send(info)
this.emit('logged',info)
this.emit("logged",info)
})
callback()
}
Expand Down
13 changes: 11 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
const { gulp,parallel,src,dest } = require("gulp")
const minify = require("gulp-minify")
const jshint = require("gulp-jshint")
function combineClasses(cb){
src("src/*.class.js").pipe(minify()).pipe(dest("./dist/"))
src("src/*.class.js")
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(minify())
.pipe(dest("./dist/"))
cb()
}
function minifyMain(cb){
src("src/index.js").pipe(minify()).pipe(dest("./dist/"))
src("src/index.js")
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(minify())
.pipe(dest("./dist/"))
cb()
}
exports.default = parallel(combineClasses,minifyMain)
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
},
"devDependencies": {
"gulp": "^4.0.0",
"gulp-minify": "^3.1.0"
"gulp-jshint": "^2.1.0",
"gulp-minify": "^3.1.0",
"jshint": "^2.10.1"
}
}
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ class LogstashTransport extends winston.Transport {
this.host = options.host
this.port = options.port
if(this.input && this.host && this.port){
if(this.input=="udp"){
if(this.input==="udp"){
this.input = new UDPInput(options)
}
else if(this.input=="tcp"){
else if(this.input==="tcp"){
this.input = new TCPInput(options)
}
else if(this.input=="websocket"){
else if(this.input==="websocket"){
this.input = new WebSocketInput(options)
}
else if(this.input=="http"){
else if(this.input==="http"){
this.input = new HTTPInput(options)
}
else {
Expand All @@ -59,7 +59,7 @@ class LogstashTransport extends winston.Transport {
log(info,callback) {
setImmediate(()=>{
this.input.send(info)
this.emit('logged',info)
this.emit("logged",info)
})
callback()
}
Expand Down

0 comments on commit a794e6e

Please sign in to comment.