{"id":26570124,"url":"https://github.com/romainprignon/unshell","last_synced_at":"2025-03-22T21:49:19.123Z","repository":{"id":33114484,"uuid":"152324868","full_name":"romainPrignon/unshell","owner":"romainPrignon","description":"Set your shell free !","archived":false,"fork":false,"pushed_at":"2024-11-10T16:36:24.000Z","size":795,"stargazers_count":4,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T20:06:40.079Z","etag":null,"topics":["exec","scripting","shell"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/romainPrignon.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-09T21:38:42.000Z","updated_at":"2024-11-10T13:47:33.000Z","dependencies_parsed_at":"2024-11-30T23:33:20.811Z","dependency_job_id":"f1d69aeb-4e94-4085-a4e4-5f9438a80512","html_url":"https://github.com/romainPrignon/unshell","commit_stats":{"total_commits":77,"total_committers":2,"mean_commits":38.5,"dds":"0.051948051948051965","last_synced_commit":"b0d12053c87ecac519018dc3a8f4f7a745b7baf1"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainPrignon%2Funshell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainPrignon%2Funshell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainPrignon%2Funshell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/romainPrignon%2Funshell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/romainPrignon","download_url":"https://codeload.github.com/romainPrignon/unshell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245025971,"owners_count":20549067,"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":["exec","scripting","shell"],"created_at":"2025-03-22T21:49:18.258Z","updated_at":"2025-03-22T21:49:19.101Z","avatar_url":"https://github.com/romainPrignon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![un](./unshell.png) shell\n\n\u003e Set your shell free !\n\n![](https://github.com/romainprignon/unshell/workflows/ci/badge.svg)\n\nCombine the flexibility of a programming language with the knowledge of shell command.\nAs developer, sometimes, we need to run shell scripts. It will be cool to do so with the familiarity of a programming language.\nAn an ops, sometimes, we need to run complex shell scripts. It will be cool to do so with the power of a programming language.\n\n## Features\n\n* **Light**: There are no dependencies\n* **Easy**: A small abstraction over `child_process`\n* **Async**: Work with async/await command\n* **Testable**: Unshell script are easily testable because they yield execution control\n\n## Setup\n\nExecute script through Shell\n```sh\nnpm install -g unshell\n```\n\nEmbedded script inside apps\n```sh\nnpm install unshell\n```\n\n## Usage\n\n### Execute script through Shell\n```\nExecute script through unshell runtime\n\nUsage:\n  unshell COMMAND [SCRIPT_PATH] [ARGS...]\n\nCommands:\n  help      Print this help message\n  run       run a script through unshell runtime\n```\n\nGiven the script: `pause.js` to pause all docker containers\n```js\nmodule.exports = function * pause () {\n  const ids = yield * fetchContainerIds()\n\n  for(const id of ids) {\n    yield `docker pause ${id}`\n  }\n}\n\nfunction * fetchContainerIds () {\n  const ids = yield `docker ps -q --no-trunc`\n\n  return ids.split('\\n').filter(Boolean)\n}\n```\n\nRun it through unshell\n```sh\nunshell run pause.js\n```\n\n### Embedded script inside apps\nGiven the precedent script `pause.js`\nRun it with `zeit/micro`\n```js\nmodule.exports = (req, res) =\u003e {\n  const {resolve} = require('path')\n  const {unshell} = require('unshell')\n\n  try {\n    const script = require(resolve('./scripts/pause.js'))\n    unshell({env: process.env})(script)\n\n    res.end('OK')\n  } catch (err) {\n    res.end('NOK')\n  }\n}\n```\n\n## Examples\nHere is some examples of what you can do with unshell\n- [Pause containers](examples/pause-resume-container)\n\n## Contribute\n Please check out the issues labeled `help wanted` or `good-first-issue`. Try npx good-first-issue unshell\n\n## License\n\nThe code is available under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromainprignon%2Funshell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fromainprignon%2Funshell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fromainprignon%2Funshell/lists"}