Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
eush77 committed Mar 29, 2015
0 parents commit 65f8fb6
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015 Eugene Sharygin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[![npm](https://nodei.co/npm/repl-here.png)](https://nodei.co/npm/repl-here/)

# repl-here

[![Dependency Status][david-badge]][david]

Node REPL that autoloads all modules in `node_modules/` at startup, just like core libs.

Inspired by [repl-it](http://npm.im/repl-it).

[david]: https://david-dm.org/eush77/repl-here
[david-badge]: https://david-dm.org/eush77/repl-here.png

## CLI

```
Usage: repl-here
```

## API

### `replHere(repl, basedir)`

Require all modules from `$basedir/node_modules` into the repl (first argument).

## Install

```
npm install -g repl-here
```

## License

MIT
21 changes: 21 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node
'use strict';

var replHere = require('./');

var Repl = require('repl');


var usage = function (code) {
console.log('Usage: repl-here');
process.exit(code || 0);
};


var main = function () {
var repl = Repl.start('> ');
replHere(repl, process.cwd());
};


(process.argv.slice(2) == '--help') ? usage() : main();
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

var camelCase = require('camel-case'),
resolveFrom = require('resolve-from');

var fs = require('fs'),
path = require('path');


module.exports = function (repl, dir) {
fs.readdir(path.join(dir, 'node_modules'), function (err, modules) {
modules.forEach(function (module) {
repl.context[camelCase(module)] = require(resolveFrom(dir, module));
});
});
};
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "repl-here",
"version": "0.0.0",
"description": "Start the REPL and load the entire node_modules/ into it",
"author": "Eugene Sharygin <[email protected]>",
"license": "MIT",
"preferGlobal": true,
"bin": {
"repl-here": "cli.js"
},
"homepage": "https://github.com/eush77/repl-here",
"repository": {
"type": "git",
"url": "https://github.com/eush77/repl-here"
},
"bugs": {
"url": "https://github.com/eush77/repl-here/issues"
},
"keywords": [
"repl",
"require",
"node_modules",
"load",
"module",
"package",
"autoload",
"quick"
],
"dependencies": {
"camel-case": "^1.1.1",
"resolve-from": "^1.0.0"
},
"devDependencies": {}
}

0 comments on commit 65f8fb6

Please sign in to comment.