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

repl-here

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

repl-here - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

62

cli.js

@@ -6,21 +6,63 @@ #!/usr/bin/env node

var helpVersion = require('help-version')(usage()),
minimist = require('minimist'),
textTable = require('text-table'),
pairs = require('object-pairs'),
chalk = require('chalk'),
tableHeader = require('table-header'),
stringLength = require('string-length');
var Repl = require('repl');
var usage = function (code) {
console.log('Usage: repl-here');
process.exit(code || 0);
function usage() {
return 'Usage: repl-here [-v | --verbose]';
}
var opts = minimist(process.argv.slice(2), {
boolean: 'verbose',
alias: { v: 'verbose' },
unknown: function () {
helpVersion.help(1);
}
});
var printNameTable = function (names) {
var table = pairs(names);
table.forEach(function (row) {
if (!row[1]) {
row[1] = chalk.red('(failed to load)');
}
});
tableHeader.add(table, ['MODULE', 'VARIABLE'], { stringLength: stringLength });
table.push(table[1]);
console.log('\r' + textTable(table));
};
var main = function () {
(function main() {
var repl = Repl.start('> ');
var names = {};
replHere(repl, process.cwd())
.on('load', function (module, name) {
names[module] = name;
})
.on('fail', function (err, module) {
console.error('\rModule failed to load: ' + module);
if (opts.verbose) {
names[module] = false;
}
else {
console.error('\rModule failed to load: ' + module);
}
})
.on('end', repl.displayPrompt.bind(repl));
};
(process.argv.slice(2) == '--help') ? usage() : main();
.on('end', function () {
if (opts.verbose) {
printNameTable(names);
}
repl.displayPrompt();
});
}());

4

index.js

@@ -26,3 +26,5 @@ 'use strict';

try {
repl.context[camelCase(module)] = require(resolveFrom(dir, module));
var name = camelCase(module);
repl.context[name] = require(resolveFrom(dir, module));
ee.emit('load', module, name);
}

@@ -29,0 +31,0 @@ catch (e) {

{
"name": "repl-here",
"version": "0.1.0",
"version": "0.2.0",
"description": "Start the REPL and load the entire ./node_modules/ into it",

@@ -36,3 +36,10 @@ "author": "Eugene Sharygin <eush77@gmail.com>",

"camel-case": "^1.1.1",
"chalk": "^1.0.0",
"help-version": "^0.2.0",
"minimist": "^1.1.1",
"object-pairs": "^0.1.0",
"resolve-from": "^1.0.0",
"string-length": "^1.0.0",
"table-header": "^0.2.0",
"text-table": "^0.2.0",
"validate-npm-package-name": "^2.2.0"

@@ -39,0 +46,0 @@ },

@@ -15,5 +15,7 @@ [![npm](https://nodei.co/npm/repl-here.png)](https://nodei.co/npm/repl-here/)

```
Usage: repl-here
Usage: repl-here [-v | --verbose]
```
`--verbose` flag prints a table describing how a particular module is named inside the REPL. Module names are effectively camel-cased versions of module names.
## API

@@ -27,2 +29,10 @@

### Event: `load`
```
ee.on('fail', function(module, name))
```
Emitted if `module` is loaded as `name`.
### Event: `fail`

@@ -34,3 +44,3 @@

Emitted whenever module fails to load.
Emitted whenever `module` fails to load.

@@ -53,9 +63,8 @@ ### Event: `end`

## Why not X?
## Related
- [repl-it](http://npm.im/repl-it): works in the context of a project, hence walks up the directory tree, parses `package.json` for dependencies and devDependencies, has options like loading main project files, etc.
- [repl-it](http://npm.im/repl-it) works in the context of a project. It walks up the directory tree, parses `package.json` for dependencies and devDependencies, has options like loading main project files, etc.
- [scratchy](http://npm.im/scratchy): does not work quite as advertised because it also walks up the directory tree and so you can't `npm install foo` and load it into the repl immediately afterwards (which is kind of a problem this module is trying to solve).
- [scratchy](http://npm.im/scratchy) is sort of a hybrid of `repl-it` and `repl-here`: it walks up the directory tree as `repl-it` does but requires everything inside `node_modules` just like `repl-here`. This means you can't simply `npm install foo` and load it into the repl immediately afterwards (which is the problem this module is trying to solve).
## Install

@@ -62,0 +71,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