🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

jsr

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsr - npm Package Compare versions

Comparing version

to
0.2.16

conf/daemon.conf

156

lib/jsrc.js

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

, scan = require('./scan')
, evaluate = require('./evaluate')
, hints = {

@@ -25,5 +26,10 @@ short: true,

'-n',
'--eval',
]
}
};
process.on('SIGINT', function() {
process.exit(0);
});
/**

@@ -49,2 +55,5 @@ * Command line client.

// unix socket path
this.socket = null;
// last command sent

@@ -76,4 +85,26 @@ this.cmd = null;

function command(value) {
var cmd = value[0]
, args = value.slice(1);
var help = require('./help')
, cmd = value[0]
, args = value.slice(1)
, completer = require('./completer');
if(('' + cmd).toLowerCase() === Constants.MAP.quit.name) {
process.exit(0);
}
// clear completion cycle on execution
completer.cycle = -1;
if(cmd === '') {
return;
}
if(cmd.toLowerCase() === help.HELP) {
help(value);
if(this.ps && this.ps.isPaused()) {
this.ps.resume();
}
return;
}
this.execute(cmd, args);

@@ -87,5 +118,2 @@ }

if(this.client) {
if(('' + cmd).toLowerCase() === Constants.MAP.quit.name) {
process.exit(0);
}
this.connected = true;

@@ -113,7 +141,9 @@ this.cmd = cmd;

this.host + ':' + this.port);
}
this.client.close(function onClose() {
this.connected = false;
}
// signal that we need to try to re-create
// the client connection
this.client = null;
// signal that we need to try to re-create
// the client connection
this.client = null;
});
}

@@ -160,2 +190,3 @@ if(this.ps) {

if(!this.connected) return 'not connected' + delimiter;
if(this.socket) return this.socket + delimiter;
var str = this.host + ':' + this.port;

@@ -171,14 +202,26 @@ if(this.db !== 0) {

*/
function interactive(wait) {
var prompt = require('cli-input');
var formats = {
location: '%s'
function interactive(wait, cb) {
var prompt = require('cli-input')
, completer = require('./completer')
, history = prompt.history
, histopts = {
exit: true, file: path.join(__dirname, '..', '.jsrc-history')};
function onHistory(err, store, hs) {
var formats = {
location: '%s'
}
this.ps = prompt(
{
infinite: true,
format: ':location',
completer: completer,
data: {location: this.location.bind(this)}});
store.mirror(this.ps.readline, null, true);
this.ps.on('value', this.command);
if(!wait) this.ps.run();
cb(err);
}
this.ps = prompt(
{
infinite: true,
format: ':location',
data: {location: this.location.bind(this)}});
this.ps.on('value', this.command);
if(!wait) this.ps.run();
history(histopts, onHistory.bind(this));
}

@@ -190,6 +233,23 @@

function createConnection(cb) {
if(this.client) {
this.client.removeAllListeners();
this.client.close();
}
this.client = create(
{host: this.host, port: this.port},
this.socket || {host: this.host, port: this.port},
{simple: true});
this.client.encoder.return_buffers = true;
function onClose(had_err) {
this.connected = false;
this.client = null;
if(this.ps) this.ps.resume();
}
this.client.once('close', onClose.bind(this));
this.client.on('error', this.error);
function addClientListeners() {

@@ -207,3 +267,2 @@ if(!this.raw) {

}
this.client.on('error', this.error);
}

@@ -213,9 +272,7 @@

if(cb && !this.auth && !this.number) {
addClientListeners();
return this.client.once('connect', cb);
}
function complete() {
if(this.raw) this.client.decoder.raw = this.raw;
if(this.raw) {
this.client.decoder.raw = this.raw;
//console.dir('setting raw mode on decoder');
}
addClientListeners();

@@ -227,2 +284,6 @@ if(cb) cb();

if(cb && !this.auth && !this.number) {
return this.client.once('connect', complete);
}
// select db

@@ -305,2 +366,6 @@ function select() {

if(res.options.s) {
this.socket = res.options.s;
}
if(res.options.n) {

@@ -319,3 +384,3 @@ this.number = parseInt(res.options.n) || 0;

// --scan overrides interactivity
// and command execution
// command execution and eval
if(res.flags.scan) {

@@ -328,10 +393,25 @@ function doScan() {

//console.dir(res);
if(res.options.eval) {
function doEval() {
evaluate(this, res);
}
return this.createConnection(doEval.bind(this));
}
if(!res.unparsed.length) {
this.console = true;
this.interactive(true);
function onConnect() {
this.connected = true;
this.ps.run();
function onReady(err) {
if(err) {
console.error(err.message);
process.exit(1);
}
function onConnect() {
this.connected = true;
this.ps.run();
}
return this.createConnection(onConnect.bind(this));
}
return this.createConnection(onConnect.bind(this));
return this.interactive(true, onReady.bind(this));
}

@@ -345,7 +425,5 @@

//console.dir('exec connect');
// not reading from stdin
if(!res.flags.x) {
run(this, this.execute, cmd, args, this.repeat, this.interval);
run(this, cmd, args, this.repeat, this.interval);
// read from stdin

@@ -361,3 +439,3 @@ }else{

args.push(buf);
run(this, this.execute, cmd, args, this.repeat, this.interval);
run(this, cmd, args, this.repeat, this.interval);
}

@@ -364,0 +442,0 @@ process.stdin.on('readable', onReadable.bind(this));

@@ -7,3 +7,2 @@ var Constants = require('jsr-constants');

* @param cli The cli program.
* @param exec The execution function to call.
* @param cmd The command name.

@@ -15,3 +14,3 @@ * @param args The arguments list.

*/
function run(cli, exec, cmd, args, repeat, interval, raw) {
function run(cli, cmd, args, repeat, interval, raw) {
repeat = repeat || 1;

@@ -28,2 +27,5 @@ interval = interval || 0;

i++;
if(i === repeat) {
process.exit(errors ? 1 : 0);
}
if(!interval) return doExec();

@@ -43,6 +45,3 @@ setTimeout(doExec, interval);

function doExec() {
if(i === repeat) {
process.exit(errors ? 1 : 0);
}
exec(cmd, args, function onReply(err, reply) {
cli.execute(cmd, args, function onReply(err, reply) {
next(err, reply);

@@ -52,5 +51,5 @@ });

doExec();
!interval ? doExec() : setTimeout(doExec, interval);
}
module.exports = run;
{
"name": "jsr",
"description": "Redis toolkit.",
"version": "0.2.11",
"version": "0.2.16",
"author": "muji <noop@xpm.io>",

@@ -14,2 +14,3 @@ "repository": {

"jsr-constants": "~1.0.34",
"ttycolor": "~0.8.13",
"cli-argparse": "~0.4.5",

@@ -27,3 +28,4 @@ "cli-input": "~0.1.1"

"docs": "npm run readme",
"readme": "mdp --force -v"
"readme": "mdp --force -v",
"import": "./sbin/import"
},

@@ -30,0 +32,0 @@ "mdp": {

@@ -18,2 +18,3 @@ Table of Contents

* [Developer](#developer)
* [Import](#import)
* [Documentation](#documentation)

@@ -48,2 +49,4 @@ * [Readme](#readme)

Or if you prefer `redis-cli -p 9736`.
Play.

@@ -151,2 +154,10 @@

### Import
To update the commands documentation run (requires curl(1) and perl(1)):
```
npm run import
```
### Documentation

@@ -153,0 +164,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet