New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bcat

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bcat - npm Package Compare versions

Comparing version 0.0.10 to 0.1.0

usage.js

136

index.js

@@ -8,34 +8,39 @@ #!/usr/bin/env node

var replaceStream = require('replacestream')
var os = require('os')
var rc = module.require('rc')
var opts = require('optimist')
.options('port', {
description: 'set a port for this bcat execution'
var argv = require('optimist')
.boolean('ansi')
.boolean('disableTabReplace')
.boolean('disableNewlineReplace')
.argv
var config = rc('bcat', {
contentType: 'text/html',
scrollDownInterval: 1000,
backgroundColor: '#000000',
foregroundColor: '#ffffff',
tabLength: 4,
tabReplace: '    ',
disableTabReplace: false,
newlineReplace: '<br />',
disableNewlineReplace: false,
ansi: false,
ansiOptions: {
foregrounds: {
'30': { style: 'color:#fffaaa' } // black
},
backgrounds: {
'40': { style: 'background-color:#fffaaa' } // black
}
}
})
.options('contentType', {
default: 'text/html',
description: 'content type header'
})
.options('ansi', {
description: 'add --ansi to show colorful ansi'
})
.options('ansiBackground', {
alias: 'ansiBg',
default: '#000000',
description: 'change the background when displaying ansi'
})
.options('backgroundColor', {
alias: 'bg',
default: '#ffffff',
description: 'change the background color in the browser'
})
var argv = opts.argv
if (argv.usage) {
console.log(opts.help())
console.log(require('./usage.js'))
process.exit(0)
}
if (argv.port) {
cat(argv.port)
if (config.port) {
cat(config.port)
} else {

@@ -50,55 +55,64 @@ findPort(8080, 8181, function(ports) {

var contentType = 'text/html';
var script = 'window.setInterval(function () { document.getElementById(\'container\').scrollIntoView(false); }, ' + config.scrollDownInterval + ')'
var ansiOptions = {
foregrounds: {
'30': { style: 'color:#fffaaa' } // black
},
backgrounds: {
'40': { style: 'background-color:#fffaaa' } // black
}
};
function cat(port) {
var script = 'window.setInterval(function () { document.getElementById(\'container\').scrollIntoView(false); }, 1000)';
var server = http.createServer(handler)
function cat(port) {
var server = http.createServer(function(request, response) {
response.setHeader('Content-Type', argv.contentType)
server.listen(port)
var style
var command = 'open'
if (argv.ansi) {
style = 'body { background-color: ' + argv.ansiBg + '; color: #ffffff }'
if (process.platform === 'win32')
command = 'start'
process.stdin
.pipe(ansi(ansiOptions))
.pipe(replaceStream('\n', '<br />'))
.pipe(response)
} else {
style = 'body { background-color: ' + argv.bg + '; }'
process.stdin.pipe(response)
child.exec(command + ' http://localhost:' + port);
function handler(request, response) {
var contentType = config.contentType
var bg = config.backgroundColor
var fg = config.foregroundColor
var stream = process.stdin
if (config.ansi) {
contentType = 'text/html'
stream = stream.pipe(ansi(config.ansiOptions))
}
response.write('<html><head><script>' + script + '</script><style>' + style + '</style></head><body><div id="container">')
if (!config.disableTabReplace) {
var tab = ''
for (var i = 0; i < config.tabLength; i++)
tab += ' '
process.stdin.on('close', function() {
console.log(1)
})
var tabStream = replaceStream(tab, config.tabReplace)
stream = stream.pipe(tabStream)
}
response.on('finish', function () {
process.exit(0)
})
});
if (!config.disableNewlineReplace) {
var osNewLineStream = replaceStream(os.EOL, config.newlineReplace)
var newLineStream = replaceStream('\n', config.newlineReplace)
server.listen(port)
stream = stream.pipe(osNewLineStream).pipe(newLineStream)
}
var command = 'open'
response.setHeader('Content-Type', contentType)
if (process.platform === 'win32')
command = 'start'
if (contentType === 'text/html') {
var style = 'body { background-color: ' + bg + '; color: ' + fg + ' }'
child.exec(command + ' http://localhost:' + port);
response.write('<html><head><script>' + script + '</script><style>' + style + '</style></head><body><div id="container">')
}
stream.pipe(response)
response.on('finish', function () {
process.exit(0)
})
}
}
{
"name": "bcat",
"version": "0.0.10",
"version": "0.1.0",
"description": "A pipe to browser utility",

@@ -31,3 +31,5 @@ "main": "index.js",

"ansi-html-stream": "0.0.2",
"replacestream": "0.0.6"
"replacestream": "0.0.6",
"rc": "~0.3.3",
"text-table": "~0.2.0"
},

@@ -34,0 +36,0 @@ "devDependencies": {

# node-bcat
Pipe to browser utility, this is (sort of a) a [bcat](https://github.com/rtomayko/bcat) clone in javascript.
Pipe to browser utility, this is (sort of a) a [bcat](https://github.com/rtomayko/bcat) clone in javascript. try --ansi for log tail fun :)
This module uses [RC](https://github.com/dominictarr/rc) to manage its configuration, so in addition to command line arguments you may save your favorite configuration in .bcatrc
## usage
```
--port set a port for this bcat execution
--contentType content type header [default: "text/html"]
--ansi add --ansi to show colorful ansi
--ansiBackground, --ansiBg change the background when displaying ansi [default: "#000000"]
--backgroundColor, --bg change the background color in the browser [default: "#ffffff"]
--port set a port for this bcat execution
--contentType content type header, must be lower case [default: "text/html"]
--backgroundColor (only in text/html) [default: "#000000"]
--foregroundColor (only in text/html) [default: "#ffffff"]
--tabLength length of a tab in spaces [default: 4]
--tabReplace tab replacement [default: "&nbsp;&nbsp;&nbsp;&nbsp;"
--disableTabReplace disable tab replacement [default: false]
--newlineReplace new line replacement [default: "<br />"
--disableNewlineReplace disable new line replacement [default: false]
--ansi show colorful ansi (implies text/html) [default: false]
--ansiOptions override replacement of ansi black color
--scrollDownInterval interval to execute javascript scroll down [default: 1000 (ms)]
```

@@ -11,0 +20,0 @@ An available port between 8080 - 8181 will be automatically picked if --port is not specified

@@ -1,6 +0,11 @@

var inspect = require('eyes').inspector()
var inspect = require('eyes').inspector(/*{ stream: null }*/);
var util = require('util')
var obj = {
x: 1,
y: 2
y: 2,
f: {
g: 3,
z: 9
}
}

@@ -10,3 +15,12 @@

inspect(obj)
inspect(obj)
inspect(obj)
setInterval(function () {
inspect(obj)
// '\32'
// var str = inspect(obj)
// for (var i in str)
// console.log(i, str.charCodeAt(i), str[i])
// str = str.replace(, '!!!')
// console.log(str)
}, 1000)
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