Socket
Socket
Sign inDemoInstall

smokestack

Package Overview
Dependencies
221
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

bin/smokestack.js

63

index.js

@@ -6,2 +6,3 @@ var quicktmp = require('quick-tmp')('smokestack')

var through = require('through2')
var rimraf = require('rimraf')
var split = require('split')

@@ -11,2 +12,3 @@ var shoe = require('shoe')

var path = require('path')
var util = require('util')
var url = require('url')

@@ -29,2 +31,3 @@ var fs = require('fs')

var launched = null
var tmp = undefined
var listen = false

@@ -35,3 +38,3 @@ var script = false

var server = http.createServer()
var port = opts.port || 15943
var port = opts.port || 0
var buffer = []

@@ -50,2 +53,4 @@

server.listen(port, function(err) {
stream.emit('listen', server)
port = server.address().port
if (err) return stream.emit('error', err)

@@ -58,2 +63,3 @@ debug('http://localhost:'+port+'/')

shoe(function(browser) {
stream.emit('connect', browser)
var handle = through(handleInput)

@@ -64,6 +70,4 @@

.pipe(handle)
.once('close', stream.shutdown)
.pipe(browser)
.once('close', function() {
launched.kill()
})
}).install(server, '/smokestack')

@@ -79,6 +83,41 @@

var key = data.shift()
console[key].apply(console, data)
stream.push(data + '\n')
next()
}
stream.shutdown = function shutdown(fn) {
// ensure shutdown only called once
if (shutdown.called) return fn && fn()
process.removeListener('exit', stream.shutdown)
process.removeListener('close', stream.shutdown)
launched && launched.removeListener('exit', stream.shutdown)
shutdown.called = true
// kill child if necessary
if (launched && !launched.killed) {
launched.once('close', next)
launched.kill()
} else {
next()
}
function next() {
// remove tmpdir if necessary
tmp ? rimraf(tmp, next) : next()
function next() {
// tmpdir if necessary
server._handle ? server.close(next) : next()
function next() {
tmp = null
stream.emit('end')
stream.emit('close')
process.nextTick(function() {
stream.emit('finish')
stream.emit('shutdown')
fn && fn()
})
}
}
}
}
return stream

@@ -100,3 +139,3 @@

var uri = 'http://localhost:'+port+'/'
var tmp = quicktmp()
tmp = quicktmp()

@@ -112,10 +151,8 @@ launched = spawn(chrome, [

, '--disable-extensions'
, '--disable-zero-browsers-open-for-tests'
, '--user-data-dir=' + tmp
]).once('exit', function() {
stream.emit('end')
process.nextTick(function() {
stream.emit('close')
stream.emit('finish')
})
})
]).once('exit', stream.shutdown)
stream.emit('spawn', launched)
process.once('exit', stream.shutdown)
process.once('close', stream.shutdown)
}

@@ -122,0 +159,0 @@

var shoe = require('shoe')('/smokestack')
var stringify = require('json-stringify-safe')
var slice = require('sliced')
var isDom = require('is-dom')
var console = window.console
var format = require('util').format

@@ -9,8 +10,4 @@ ;['error'

, 'log'
, 'debug'
, 'warn'
, 'dir'
, 'time'
, 'timeEnd'
, 'trace'
, 'assert'
].forEach(function(k) {

@@ -21,5 +18,17 @@ var old = console[k]

console[k] = function() {
// keep original args so browser can log as usual
var args = slice(arguments)
var data = stringify(prefix.concat(args))
// prepare args for transport
var cleanArgs = args.map(function(item) {
// no sensible default for stringifying
// DOM Elements nicely so just toString and let
// whoever is logging handle stringification.
if (item && isDom(item)) return item.toString()
return item
})
var output = format.apply(null, cleanArgs)
var data = JSON.stringify(prefix.concat(output))
shoe.write(data)

@@ -41,1 +50,10 @@ shoe.write('\n')

}
shoe.on('end', function() {
close()
})
window.onerror = function (message, filename, lineno, colno, error) {
console.error("%s\n%s", message, error && error.stack.toString());
window.close()
}
{
"name": "smokestack",
"version": "1.0.0",
"version": "2.0.0",
"description": "Pipe your JavaScript into a browser, logging console output in Node",
"main": "index.js",
"bin": {
"smokestack": "bin/smokestack.js"
},
"license": "MIT",
"scripts": {
"prepublish": "browserify instrument.js -o bundle.js",
"test": "npm run prepublish && node proof.js"
"pretest": "npm prune && npm run prepublish",
"test": "tape test/*.js"
},
"author": {
"name": "Hugh Kennedy",
"email": "hughskennedy@gmail.com",
"url": "http://hughsk.io/"
},
"author": "Hugh Kennedy <hughskennedy@gmail.com> (http://hughsk.io/)",
"dependencies": {
"chrome-location": "^1.0.1",
"debug": "^2.0.0",
"is-dom": "~1.0.4",
"minimist": "~1.1.0",
"quick-tmp": "0.0.0",
"rimraf": "~2.2.8",
"shoe": "0.0.15",
"split": "^0.3.0",
"tap-finished": "0.0.1",
"through2": "^0.6.2"
},
"devDependencies": {
"bl": "~0.9.3",
"browserify": "^6.0.3",
"json-stringify-safe": "^5.0.0",
"sliced": "0.0.5"
"sliced": "0.0.5",
"tape": "~3.0.0"
},

@@ -49,3 +55,6 @@ "repository": {

"url": "https://github.com/hughsk/smokestack/issues"
},
"directories": {
"test": "test"
}
}

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc