Socket
Socket
Sign inDemoInstall

replify

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.1.3

8

History.md
1.1.3 / 2013-08-14
==================
* Fixed 'ctx not defined'. (@thlorenz)
* Expose `useColors` REPL configuration. (@thlorenz)
* `socket.end` should be bound to the `socket` object. (@kitcambridge)
* `getConnections` was not in v0.8, switch to checking for `listen`.
1.1.2 / 2013-08-12

@@ -3,0 +11,0 @@ ==================

2

package.json
{
"name": "replify",
"version": "1.1.2",
"version": "1.1.3",
"description": "Easily add a REPL to your Node.js app.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -22,10 +22,11 @@ /*!

options.app || (options.app = app)
options.columns || (options.columns = 132)
options.contexts || (options.contexts = (typeof contexts === 'object') ? contexts : {})
options.extension || (options.extension = '.sock')
options.logger || (options.logger = console)
options.name || (options.name = 'replify')
options.path || (options.path = '/tmp/repl')
options.start || (options.start = repl.start)
options.app || (options.app = app)
options.columns || (options.columns = 132)
options.contexts || (options.contexts = (typeof contexts === 'object') ? contexts : {})
options.extension || (options.extension = '.sock')
options.logger || (options.logger = console)
options.name || (options.name = 'replify')
options.path || (options.path = '/tmp/repl')
options.start || (options.start = repl.start)
options.hasOwnProperty('useColors') || (options.useColors = true)

@@ -55,2 +56,3 @@ options.replPath = options.path + '/' + options.name + options.extension

, useGlobal: false
, useColors: options.useColors
}

@@ -72,3 +74,3 @@

rep = options.start(replOptions)
rep.on('exit', socket.end)
rep.on('exit', socket.end.bind(socket))
rep.on('error', function (err) {

@@ -95,3 +97,3 @@ logger.error('repl error', err)

} else {
rep.context[key] = ctx[key]
rep.context[key] = options.contexts[key]
}

@@ -98,0 +100,0 @@ })

var fs = require('fs')
, http = require('http')
, net = require('net')
, replify = require('../')

@@ -8,2 +9,19 @@ , tap = require('tap')

/**
* Support
*/
function connect(name) {
return net.connect({ path: '/tmp/repl/' + name + '.sock' })
}
function sendMsg(socket, msg, cb) {
var data = ''
socket.on('data', function (buf) { data += buf.toString() })
socket.on('end', function () { cb(data) })
socket.write(msg);
socket.end();
}
/**
* Cleanup

@@ -28,2 +46,3 @@ */

var app = http.createServer()
t.on('end', app.close.bind(app))

@@ -34,3 +53,8 @@ app.listen(9999, function onListening () {

t.ok(fs.statSync('/tmp/repl/net-test.sock'), 'repl file exists')
t.end()
var conn = net.connect('/tmp/repl/net-test.sock')
conn.resume()
conn.on('connect', conn.end.bind(conn, '.exit\n'))
conn.on('close', t.end.bind(t))
}, 250)

@@ -40,3 +64,59 @@ })

replify('net-test', app)
})
test('replify has app in context', function (t) {
var app = http.createServer()
t.on('end', app.close.bind(app))
app.listen(9999, function onListening () {
setTimeout(function () {
var socket = connect('net-test')
socket.on('connect', function () {
sendMsg(socket, 'app.listen\n', function (res) {
t.similar(res, /app.listen\r\n\[Function\]/, 'can access app.listen property')
t.end()
})
})
}, 250)
})
replify({ name: 'net-test', useColors: false }, app)
})
test('replify accepts custom context as last param', function (t) {
var app = http.createServer()
t.on('end', app.close.bind(app))
app.listen(9999, function onlistening () {
setTimeout(function () {
var socket = connect('net-test')
socket.on('connect', function () {
sendMsg(socket, 'node\n', function (res) {
t.ok(/up/.test(res), 'can access properties in custom context')
t.end()
})
})
}, 250)
})
replify({ name: 'net-test', usecolors: false }, app, { node: 'up' })
})
test('replify accepts custom context as options property', function (t) {
var app = http.createServer()
t.on('end', app.close.bind(app))
app.listen(9999, function onlistening () {
setTimeout(function () {
var socket = connect('net-test')
socket.on('connect', function () {
sendMsg(socket, 'node\n', function (res) {
t.ok(/up/.test(res), 'can access properties in custom context')
t.end()
})
})
}, 250)
})
replify({ name: 'net-test', usecolors: false, contexts: { node: 'up' } }, app)
})
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