{"id":15700657,"url":"https://github.com/fvictorio/repl-maker","last_synced_at":"2025-08-23T02:17:42.343Z","repository":{"id":141787731,"uuid":"168428997","full_name":"fvictorio/repl-maker","owner":"fvictorio","description":"Make a customized node REPL with ease","archived":false,"fork":false,"pushed_at":"2019-02-05T17:12:14.000Z","size":6,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-23T01:57:39.768Z","etag":null,"topics":["cli","nodejs","repl","tool"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fvictorio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-30T23:03:34.000Z","updated_at":"2019-05-23T18:37:35.000Z","dependencies_parsed_at":"2023-04-14T09:35:54.374Z","dependency_job_id":null,"html_url":"https://github.com/fvictorio/repl-maker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fvictorio/repl-maker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvictorio%2Frepl-maker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvictorio%2Frepl-maker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvictorio%2Frepl-maker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvictorio%2Frepl-maker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fvictorio","download_url":"https://codeload.github.com/fvictorio/repl-maker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fvictorio%2Frepl-maker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271732362,"owners_count":24811309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","nodejs","repl","tool"],"created_at":"2024-10-03T19:51:52.187Z","updated_at":"2025-08-23T02:17:42.328Z","avatar_url":"https://github.com/fvictorio.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# repl-maker\n\nMake a customized node REPL with ease.\n\n## The problem\n\nBuilding a custom REPL is not hard with the [`repl`](https://nodejs.org/api/repl.html)\nmodule, but you need a non-trivial amount of boilerplate to have things you\nmight expect out of the box.\n\n## This solution\n\nThis module exposes a function that creates and starts a\n[`REPLServer`](https://nodejs.org/api/repl.html#repl_class_replserver) with some\npacked features:\n\n- **Multiline expressions**: You don't have to write every statement in a single\n  line.\n- **Command history**: You can pass a path to a history file that will save the\n  command history between sessions (using\n  [`repl.history`](https://www.npmjs.com/package/repl.history)).\n- **Promises evaluation**: Avoid doing things like `(async () =\u003e { const foo =\n  await getFoo(); console.log(foo) })()`: every expression that evaluates to a\n  promise will be waited. Just `getFoo()` will work.\n\n## Usage\n\nInstall it:\n\n```\nnpm install repl-maker\n```\n\ncreate your repl:\n\n```javascript\nconst path = require('path')\nconst os = require('os')\nconst makeRepl = require('repl-maker')\n\nconst historyFile = path.join(os.homedir(), '.my_repl_history')\nconst context = {\n  answer: 42,\n  square: (x) =\u003e x*x\n}\n\nmakeRepl({ historyFile, context })\n```\n\nand use it:\n\n```\n$ node index.js\n\u003e answer\n42\n\u003e Promise.resolve(3)\n3\n\u003e square(5)\n25\n```\n\n## Configuration\n\nThe `makeRepl` function accepts an object with these options:\n\n- `prompt` _(string)_ - The prompt of your REPL (default: `\u003e `)\n- `context` _(object)_: Every key in this object will be available as a local\n  variable (default: `{}`)\n- `historyFile` _(string)_ - Path to a file that will save the command history\n  (default: `null`, meaning that no history file will be generated)\n- `evalAsync` _(boolean)_ - Configures if the REPL waits until promises are resolved\n  or not (default: `true`)\n- `recoverErrors` _(boolean)_ - Configures if multiline expressions are allowed\n  or not (default: `true`)\n- `onExit` _(function)_ - A callback that will be executed when the user exits\n  the REPL (default: `null`)\n\nIt returns a [`REPLServer`](https://nodejs.org/api/repl.html#repl_class_replserver) that you can further\ncustomize.\n\n## Use cases\n\nIf you find yourself opening a node REPL and requiring some stuff of your\nproject to try it out, then this module can help you.\n\nA very straightforward example is an express server with some models. You can\ncreate a minimal `repl.js` file:\n\n```javascript\nconst makeRepl = require('repl-maker')\nconst db = require('./models')\n\nmakeRepl({\n  context: { db }\n})\n```\n\nand add a npm script `\"repl\": \"node repl.js\"`. Then you can start it and\ninteract with your models:\n\n```\nnpm run repl\n\u003e db.findUser({ id: 1 }).then(user =\u003e user.name)\n'John Doe'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvictorio%2Frepl-maker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffvictorio%2Frepl-maker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffvictorio%2Frepl-maker/lists"}