{"id":15657379,"url":"https://github.com/typicode/homerun","last_synced_at":"2025-06-19T23:39:21.377Z","repository":{"id":23683049,"uuid":"27054640","full_name":"typicode/homerun","owner":"typicode","description":"Turn npm package scripts into CLI commands","archived":false,"fork":false,"pushed_at":"2015-09-09T05:03:38.000Z","size":222,"stargazers_count":23,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-09T03:49:51.527Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/typicode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-24T00:55:32.000Z","updated_at":"2024-06-14T06:09:38.000Z","dependencies_parsed_at":"2022-09-03T07:41:19.332Z","dependency_job_id":null,"html_url":"https://github.com/typicode/homerun","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/typicode/homerun","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Fhomerun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Fhomerun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Fhomerun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Fhomerun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/typicode","download_url":"https://codeload.github.com/typicode/homerun/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/typicode%2Fhomerun/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260851172,"owners_count":23072551,"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","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":[],"created_at":"2024-10-03T13:06:31.913Z","updated_at":"2025-06-19T23:39:16.358Z","avatar_url":"https://github.com/typicode.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Homerun [![](https://travis-ci.org/typicode/homerun.svg?branch=master)](https://travis-ci.org/typicode/homerun) [![npm version](https://badge.fury.io/js/homerun.svg)](http://badge.fury.io/js/homerun)\n\n\u003e Turn npm package scripts into CLI commands\n\nSince npm 2.0, you can pass arguments to scripts... wait... what if you could use that for creating CLIs?\nHomerun is a little experiment that lets you just do that. If you need more, I highly recommend [minimist](https://github.com/substack/minimist).\n\n## Usage\n\nLet's say you have a script called `add` that you can run this way:\n\n```bash\nnpm run add -- 1 2\n3\n```\n\nInstall homerun\n\n```bash\nnpm install homerun --save\n```\n\nAdd it to your `package.json`\n\n```javascript\n{\n  \"name\": \"cli\"\n  \"bin\": \"./node_modules/.bin/homerun\" // \u003c-- here\n  \"scripts\": {\n    \"add\": \"node commands/add\"\n  }\n}\n```\n\nNow, without any other setup, if you `npm link` or `npm publish` you get a CLI for free:\n\n```bash\ncli add 1 2\n3\n```\n\nAnd of course, while you develop, you can still use `npm run add -- 1 2` to test your command. \n\n## Options\n\nHomerun will use these scripts in case no command is provided or matches.\n\n```javascript\n\"scripts\": {\n  \"index\": \"node commands/index\"  // no command provided\n  \"unknown\": \"node commands/help\" // unknown command provided\n}\n```\n\n## Module\n\nIf you need to customize, homerun can be used as a module.\n\n```javascript\n// index.js\nvar homerun = require('homerun')\nvar scripts = require('./package.json').scripts\n\nhomerun(scripts, process.argv).spawn()\n```\n\n```javascript\n// package.json\n{\n  \"bin\": \"index.js\"\n}\n```\n\n## Test\n\nTo test your commands, you can use `homerun.exec()`\n\n```javascript\nvar assert = require('assert')\n\nvar argv = [,, 'add', '1', '2']\n\nhomerun(scripts, argv).exec(function(err, stdout, stderr) {\n  assert.equal(err, null)\n  assert.equal('', stderr)\n  assert.equal('3\\n', stdout)\n})\n```\n\n## Limit\n\nHomerun doesn't support multiple commands. For example, `echo foo \u0026\u0026 echo bar` won't work.\n\n## License\n\nMIT - [Typicode](https://github.com/typicode)\n\n![](http://i.imgur.com/Bs7wA8v.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypicode%2Fhomerun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftypicode%2Fhomerun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftypicode%2Fhomerun/lists"}