Comparing version 1.0.1 to 1.0.2
18
index.js
@@ -5,3 +5,19 @@ 'use strict'; | ||
module.exports = REPLIE; | ||
/* | ||
REPLIE Options | ||
{ | ||
prompt: {String} Repl Command Line Prompt, | ||
server: {Object} Express server instance, leave undefined and pass options.startSever to have replie create a server instance, | ||
port: {Number} Port for express server to listen on, will default to 5000 if not specified (this is only used if you are passing options.startServer), | ||
modules: {Array} Array of internal and external modules for replie to load into its context, see example below, | ||
namespace: {String} Optional namespacing for web socket, | ||
logger: {Function} Optional logger function, defaults to console.log, | ||
onError: {Function} Error handling function, | ||
connectionUrl: {String} Optional connection path if replie is starting server, | ||
templatePath: {String} File path for html if replie is starting server, | ||
connectionMessage: {String} Message for socket emitter on connection, | ||
replConnectionCallback: {Function} Optional socket connection callback function defaults to emitting connectionMessage, | ||
serverConnectionCallback: {Function} Optional server connection callback if replie is starting server, defaults to sendFile using templatePath | ||
} | ||
*/ | ||
// Example | ||
@@ -8,0 +24,0 @@ // var repl = new REPLIE({ |
@@ -104,3 +104,6 @@ 'use strict'; | ||
}; | ||
if (this.server && !options.startServer) { | ||
if (options.io_server) { | ||
this.io = options.io_server; | ||
} | ||
else if (this.server && !options.startServer) { | ||
this.io = sockets(this.server); | ||
@@ -137,2 +140,3 @@ } | ||
stream.resume = function () {}; | ||
stream.pause = function () {}; | ||
socket.on('stdin', function (data) { | ||
@@ -142,5 +146,17 @@ stream.emit('data', data + '\r\n'); | ||
}; | ||
this._getStream = function () { | ||
return stream; | ||
}; | ||
if (typeof this.namespace === 'string') { | ||
this.namespaces[this.namespace] = this.io.of('/' + this.namespace); | ||
this.namespaces[this.namespace].on('connection', function (socket) { | ||
socket.on('disconnect', function () { | ||
self.disconnect(); | ||
}); | ||
socket.on('end', function () { | ||
self.disconnect(); | ||
}); | ||
socket.on('close', function () { | ||
self.disconnect(); | ||
}); | ||
configureConnection.call(self, socket); | ||
@@ -160,2 +176,11 @@ }); | ||
configureConnection.call(self, socket); | ||
socket.on('disconnect', function () { | ||
self.disconnect(); | ||
}); | ||
socket.on('end', function () { | ||
self.disconnect(); | ||
}); | ||
socket.on('close', function () { | ||
self.disconnect(); | ||
}); | ||
}); | ||
@@ -173,6 +198,18 @@ this.io.on('error', function (err) { | ||
REPLIE.prototype.disconnect = function () { | ||
this.logger('User Disconnected'); | ||
var self = this, | ||
rp = self._getREPL(); | ||
if (rp) { | ||
self._getStream().emit('data', '.exit\r\n'); | ||
} | ||
return self; | ||
}; | ||
REPLIE.prototype.extendContext = function (options, callback) { | ||
var self = this, | ||
context = self._getREPL().context, | ||
extend = function (nodeModule) { | ||
return new Bluebird(function (resolve, reject) { | ||
return new Bluebird(function (resolve) { | ||
if (typeof nodeModule === 'object') { | ||
@@ -187,3 +224,3 @@ if (nodeModule.type === 'internal') { | ||
else { | ||
self.context[path.basename(nodeModule.name, '.js')] = require(path); | ||
context[path.basename(nodeModule.name, '.js')] = require(path); | ||
resolve(); | ||
@@ -195,3 +232,3 @@ } | ||
if (nodeModule.name === 'shelljs') { | ||
self.context.exec = exec; | ||
context.exec = exec; | ||
resolve(); | ||
@@ -203,3 +240,3 @@ } | ||
var mod = require(nodeModule.name); | ||
self.context[contextName] = mod; | ||
context[contextName] = mod; | ||
resolve(); | ||
@@ -212,3 +249,3 @@ } | ||
var installed = require(nodeModule.name); | ||
self.context[contextName] = installed; | ||
context[contextName] = installed; | ||
resolve(); | ||
@@ -215,0 +252,0 @@ } |
{ | ||
"name": "replie", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A basic web socket based repl", | ||
@@ -14,11 +14,56 @@ "main": "index.js", | ||
], | ||
"author": "Jan Bialostok", | ||
"license": "ISC", | ||
"author": { | ||
"name": "Jan Bialostok", | ||
"email": "janbialostok@gmail.com", | ||
"url": "https://github.com/janbialostok" | ||
}, | ||
"contributors": [{ | ||
"name": "Yaw Joseph Etse", | ||
"email": "yaw.etse@gmail.com", | ||
"url": "http://about.me/yawjosephetse" | ||
}], | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/janbialostok/Replie.git" | ||
}, | ||
"dependencies": { | ||
"bluebird": "^3.0.5", | ||
"express": "^4.13.3", | ||
"shelljs": "^0.5.3", | ||
"socket.io": "^1.3.7", | ||
"util-extend": "^1.0.1" | ||
} | ||
}, | ||
"devDependencies": { | ||
"express": "^4.13.3", | ||
"socket.io": "^1.3.7" | ||
}, | ||
"gitHead": "fb22d1d67078d6ac68ae457fe431462e8d66d17e", | ||
"bugs": { | ||
"url": "https://github.com/janbialostok/Replie/issues" | ||
}, | ||
"homepage": "https://github.com/janbialostok/Replie#readme", | ||
"_id": "replie@1.0.191", | ||
"_shasum": "d75b4fcfe4f7a41fd43821a14aecdd708221f8d8", | ||
"_from": "replie@*", | ||
"_npmVersion": "2.11.2", | ||
"_nodeVersion": "0.12.6", | ||
"_npmUser": { | ||
"name": "janbialostok", | ||
"email": "janbialostok@gmail.com" | ||
}, | ||
"dist": { | ||
"shasum": "d75b4fcfe4f7a41fd43821a14aecdd708221f8d8", | ||
"tarball": "http://registry.npmjs.org/replie/-/replie-1.0.191.tgz" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "janbialostok", | ||
"email": "janbialostok@gmail.com" | ||
},{ | ||
"name": "Yaw Joseph Etse", | ||
"email": "yaw.etse@gmail.com", | ||
"url": "http://about.me/yawjosephetse" | ||
} | ||
], | ||
"directories": {}, | ||
"_resolved": "https://registry.npmjs.org/replie/-/replie-1.0.191.tgz" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
15755
3
10
336
1
0
8
2
2
- Removedexpress@^4.13.3
- Removedsocket.io@^1.3.7
- Removedaccepts@1.3.31.3.8(transitive)
- Removedafter@0.8.2(transitive)
- Removedarray-flatten@1.1.1(transitive)
- Removedarraybuffer.slice@0.0.6(transitive)
- Removedbacko2@1.0.2(transitive)
- Removedbase64-arraybuffer@0.1.5(transitive)
- Removedbase64id@1.0.0(transitive)
- Removedbetter-assert@1.0.2(transitive)
- Removedblob@0.0.4(transitive)
- Removedbody-parser@1.20.3(transitive)
- Removedbytes@3.1.2(transitive)
- Removedcall-bind-apply-helpers@1.0.2(transitive)
- Removedcall-bound@1.0.4(transitive)
- Removedcallsite@1.0.0(transitive)
- Removedcomponent-bind@1.0.0(transitive)
- Removedcomponent-emitter@1.1.21.2.1(transitive)
- Removedcomponent-inherit@0.0.3(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removedcontent-type@1.0.5(transitive)
- Removedcookie@0.3.10.7.1(transitive)
- Removedcookie-signature@1.0.6(transitive)
- Removeddebug@2.2.02.3.32.6.9(transitive)
- Removeddepd@2.0.0(transitive)
- Removeddestroy@1.2.0(transitive)
- Removeddunder-proto@1.0.1(transitive)
- Removedee-first@1.1.1(transitive)
- Removedencodeurl@1.0.22.0.0(transitive)
- Removedengine.io@1.8.5(transitive)
- Removedengine.io-client@1.8.6(transitive)
- Removedengine.io-parser@1.3.2(transitive)
- Removedes-define-property@1.0.1(transitive)
- Removedes-errors@1.3.0(transitive)
- Removedes-object-atoms@1.1.1(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedetag@1.8.1(transitive)
- Removedexpress@4.21.2(transitive)
- Removedfinalhandler@1.3.1(transitive)
- Removedforwarded@0.2.0(transitive)
- Removedfresh@0.5.2(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-intrinsic@1.3.0(transitive)
- Removedget-proto@1.0.1(transitive)
- Removedgopd@1.2.0(transitive)
- Removedhas-binary@0.1.7(transitive)
- Removedhas-cors@1.1.0(transitive)
- Removedhas-symbols@1.1.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhttp-errors@2.0.0(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedindexof@0.0.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedipaddr.js@1.9.1(transitive)
- Removedisarray@0.0.1(transitive)
- Removedjson3@3.3.2(transitive)
- Removedmath-intrinsics@1.1.0(transitive)
- Removedmedia-typer@0.3.0(transitive)
- Removedmerge-descriptors@1.0.3(transitive)
- Removedmethods@1.1.2(transitive)
- Removedmime@1.6.0(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removedms@0.7.10.7.22.0.02.1.3(transitive)
- Removednegotiator@0.6.10.6.3(transitive)
- Removedobject-assign@4.1.0(transitive)
- Removedobject-component@0.0.3(transitive)
- Removedobject-inspect@1.13.4(transitive)
- Removedon-finished@2.4.1(transitive)
- Removedoptions@0.0.6(transitive)
- Removedparsejson@0.0.3(transitive)
- Removedparseqs@0.0.5(transitive)
- Removedparseuri@0.0.5(transitive)
- Removedparseurl@1.3.3(transitive)
- Removedpath-to-regexp@0.1.12(transitive)
- Removedproxy-addr@2.0.7(transitive)
- Removedqs@6.13.0(transitive)
- Removedrange-parser@1.2.1(transitive)
- Removedraw-body@2.5.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsend@0.19.0(transitive)
- Removedserve-static@1.16.2(transitive)
- Removedsetprototypeof@1.2.0(transitive)
- Removedside-channel@1.1.0(transitive)
- Removedside-channel-list@1.0.0(transitive)
- Removedside-channel-map@1.0.1(transitive)
- Removedside-channel-weakmap@1.0.2(transitive)
- Removedsocket.io@1.7.4(transitive)
- Removedsocket.io-adapter@0.5.0(transitive)
- Removedsocket.io-client@1.7.4(transitive)
- Removedsocket.io-parser@2.3.1(transitive)
- Removedstatuses@2.0.1(transitive)
- Removedto-array@0.1.4(transitive)
- Removedtoidentifier@1.0.1(transitive)
- Removedtype-is@1.6.18(transitive)
- Removedultron@1.0.2(transitive)
- Removedunpipe@1.0.0(transitive)
- Removedutils-merge@1.0.1(transitive)
- Removedvary@1.1.2(transitive)
- Removedws@1.1.5(transitive)
- Removedwtf-8@1.0.0(transitive)
- Removedxmlhttprequest-ssl@1.6.3(transitive)
- Removedyeast@0.1.2(transitive)