Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gulp-ws-sender

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-ws-sender - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

src/broadcast.js

44

index.js

@@ -1,42 +0,8 @@

'use strict'
const gutil = require('gulp-util')
const through = require('through2')
const chalk = require('chalk')
const date = require('date-and-time')
const server = require('./src/server')
const broadcast = require('./src/broadcast')
const getMessage = type => {
const time = date.format(new Date(), 'HH:mm:ss')
return `[${chalk.gray(time)}] ${chalk.yellow(type)} was sent`
}
module.exports = options => {
const { client: ws, type } = options
return through.obj(function(file, enc, cb) {
if (file.isNull()) {
cb(null, file)
return
}
if (file.isStream()) {
cb(new gutil.PluginError('gulp-ws-sender', 'Streaming not supported'))
return
}
try {
const prefix = type === 'js' ? 'js' : 'st'
ws.send(prefix + file.contents.toString())
file.contents = Buffer.from(file.contents)
this.push(file)
console.log(getMessage(type))
} catch (err) {
this.emit('error', new gutil.PluginError('gulp-ws-sender', err))
console.log(err)
}
cb()
})
module.exports = {
server,
broadcast
}
{
"name": "gulp-ws-sender",
"version": "1.0.0",
"version": "1.1.0",
"description": "to send js and css to your websocket server",

@@ -14,6 +14,10 @@ "main": "index.js",

"chalk": "^2.4.1",
"date-and-time": "^0.6.3",
"gulp-util": "^3.0.8",
"through2": "^3.0.0"
"through2": "^3.0.0",
"ws": "^6.1.0"
},
"repository": {
"type" : "git",
"url" : "https://github.com/bercly0b/gulp-ws-sender"
}
}
## usage
```sh
const gulp = require('gulp')
const sender = require('gulp-ws-sender')
const WebSocket = require('ws')
const broadcast = require('gulp-ws-sender').broadcast(port)
const server = require('gulp-ws-sender').server
const ws = new WebSocket('ws://localhost:9999')
gulp.task('styles', () => {
return gulp.src('src/**/*.css')
.pipe(sender({
socketClient: ws,
type: 'css'

@@ -17,2 +14,4 @@ }))

})
gulp.task('server', () => server({ port: port }))
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc