Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

n_shell

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

n_shell - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

2

package.json
{
"name": "n_shell",
"version": "0.2.0",
"version": "0.3.0",
"description": "A node REPL with ShellJS loaded by default",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -95,7 +95,7 @@ # n_shell

- `--no_global [PREFIX]`, `--local [PREFIX]`, `-n [PREFIX]`: Start a node REPL
with the equivalent of `var PREFIX = require('shelljs')`. `PREFIX`
defaults to `shell`, if not specified.
with the equivalent of `var PREFIX = require('shelljs')`. `PREFIX` defaults
to `shell`, if not specified.
- `--use_strict`: enforce strict mode (default is false)
- `--prompt <FORMAT>`: use this format to generate the REPL prompt. Default is
"`shelljs %v%l $ `"
"`shelljs %v%l $ `"
- `%%`: a literal `%` sign

@@ -108,5 +108,55 @@ - `%v`: show the current version (from `package.json`)

PR](https://github.com/nfischer/n_shell/compare)
- `--inspect`: an experimental switch to add a `.inspect()` method to the
output of each command, to make it look less cluttered. This doesn't change
the return values, it only changes what they look like on the REPL. For
example:
```
shelljs $ ls();
bar
file.txt
foo
shelljs $ cat('file.txt');
hello world
shelljs $ cat('file.txt').stdout; // all the attributes from before still exist
'hello world\n'
```
instead of the very messy-looking (on shelljs v0.7):
```javascript
shelljs $ ls();
[ 'bar',
'file.txt',
'foo',
stdout: 'bar\nfile.txt\nfoo\n',
stderr: null,
code: 0,
to: [Function],
// Even more methods...
grep: [Function],
exec: [Function] }
shelljs $ cat('file.txt');
{ [String: 'hello world\n']
stdout: 'hello world\n',
stderr: null,
code: 0,
to: [Function],
// Even more methods...
grep: [Function],
exec: [Function] }
shelljs $ cat('file.txt').stdout; // all the attributes from before still exist
'hello world\n'
```
**Note**: the `--inspect` option is not availalbe for `--local` mode. Also,
if you like the feature, let me know and it may work its way into ShellJS
itself if it has enough support.
## History
Similarly to `n_`, `n_shell` stores REPL history under `~/.n_shell_history`.

@@ -23,4 +23,6 @@ 'use strict';

}
shell.clear = require('clear'); // add in clear command, for convenience
// Polyfills for commands that shelljs doesn't have yet
if (!shell.clear) shell.clear = require('clear');
// Create the prompt

@@ -48,2 +50,25 @@ var myprompt = argv.prompt || 'shelljs %v%l $ ';

function wrap(fun, key) {
if (typeof fun !== 'function') {
return fun; // not a function
} else {
return function() {
var ret = fun.apply(this, arguments);
if (ret instanceof Object) {
// Polyfill .inspect() method
if (!ret.inspect) ret.inspect = function() {
if (key === 'echo' || key === 'exec') return '';
if (this.hasOwnProperty('stdout'))
return this.stdout;
else if (Array.isArray(this))
return this.join('\n');
else
return this;
};
}
return ret;
};
}
}
argv.no_global = argv.no_global || argv.local || argv.n;

@@ -56,3 +81,3 @@ if (argv.no_global) {

for (var key in shell) {
replServer.context[key] = shell[key];
replServer.context[key] = argv.inspect ? wrap(shell[key], key) : shell[key];
}

@@ -59,0 +84,0 @@ }

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