{"id":15552518,"url":"https://github.com/bahmutov/execa-wrap","last_synced_at":"2025-09-28T20:31:10.929Z","repository":{"id":51815205,"uuid":"101714255","full_name":"bahmutov/execa-wrap","owner":"bahmutov","description":"Wraps execa and makes output suitable for snapshot testing","archived":false,"fork":false,"pushed_at":"2025-01-01T07:34:10.000Z","size":158,"stargazers_count":5,"open_issues_count":15,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-13T00:02:07.553Z","etag":null,"topics":["child-process","exec","execa","snapshot","testing","wrapper"],"latest_commit_sha":null,"homepage":null,"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/bahmutov.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":"2017-08-29T03:21:14.000Z","updated_at":"2022-01-14T17:49:12.000Z","dependencies_parsed_at":"2024-06-19T02:10:19.427Z","dependency_job_id":"feab8d9c-10d8-4dc5-bb62-63c6cdfbf365","html_url":"https://github.com/bahmutov/execa-wrap","commit_stats":{"total_commits":52,"total_committers":3,"mean_commits":"17.333333333333332","dds":0.5,"last_synced_commit":"e57f3dee70cd182172d19103110b3791c48e67b2"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fexeca-wrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fexeca-wrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fexeca-wrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bahmutov%2Fexeca-wrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bahmutov","download_url":"https://codeload.github.com/bahmutov/execa-wrap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234558807,"owners_count":18852283,"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":["child-process","exec","execa","snapshot","testing","wrapper"],"created_at":"2024-10-02T14:20:34.042Z","updated_at":"2025-09-28T20:31:10.573Z","avatar_url":"https://github.com/bahmutov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# execa-wrap\n\n\u003e Wraps [execa][execa] and makes output suitable for snapshot testing\n\n[![NPM][npm-icon] ][npm-url]\n\n[![Build status][ci-image] ][ci-url]\n[![semantic-release][semantic-image] ][semantic-url]\n[![js-standard-style][standard-image]][standard-url]\n[![Build status](https://ci.appveyor.com/api/projects/status/k0x59r7f4qem7nvb?svg=true)](https://ci.appveyor.com/project/RandallKent/execa-wrap)\n[![renovate-app badge][renovate-badge]][renovate-app]\n\n## Install\n\nRequires [Node](https://nodejs.org/en/) version 6 or above.\n\n```sh\nnpm install --save execa-wrap\n```\n\n## Use\n\nFrom the tests, include both this module and\n[snap-shot-it](https://github.com/bahmutov/snap-shot-it)\n\n```js\nconst execaWrap = require('execa-wrap')\nconst snapshot = require('snap-shot-it')\ndescribe('execa-wrap', () =\u003e {\n  it('ls', () =\u003e {\n    return execaWrap('ls', ['src']).then(snapshot)\n  })\n})\n```\n```text\n$ cat __snapshots__/execa-wrap-spec.js\nexports['execa-wrap ls 1'] = `\n  command: ls src\n  code: 0\n  failed: false\n  killed: false\n  signal: null\n  timedOut: false\n\n  stdout:\n  -------\n  execa-wrap-spec.js\n  index.js\n  -------\n  stderr:\n  -------\n\n  -------\n  `\n```\n\nYou probably want to cleanup the output before the snapshot step. For example, you might\nwant to remove timings, stack traces, etc.\n\nIf the program fails, the output and everything else will be processed the same way.\nThus you can test the programs returning non-zero exit codes by just attaching resolved\npromise callback\n\n```js\nconst execaWrap = require('execa-wrap')\nexecaWrap('failing-command', ['its', 'arguments'])\n  .then(output =\u003e {\n    // output will be text like above but with\n    // details like exit code and stderr\n  })\n```\n\nYou can pass other options to [execa][execa], for example environment variables\n\n```js\nconst execaWrap = require('execa-wrap')\nexecaWrap('failing-command', ['its', 'arguments'], {\n  env: {\n    FOO: 'foo'\n  }\n})\n```\n\n### Filtering properties\n\nIf you are not interested in every returned property, you can filter and get only some\nproperties. For example, let us grab `command` and `stdout`\n\n```js\nexecaWrap('ls', ['src'], {filter: ['cmd', 'stdout']})\n// command: ls src\n// stdout\n// ------\n```\n\nFor a single filter, just use a string or single item array\n\n```js\nexecaWrap('ls', ['src'], {filter: 'cmd'})\n// command: ls src\n```\n\n## Debug\n\nTo see internal log messages, run with `DEBUG=execa-wrap` environment variable\n\n### Small print\n\nAuthor: Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt; \u0026copy; 2017\n\n* [@bahmutov](https://twitter.com/bahmutov)\n* [glebbahmutov.com](https://glebbahmutov.com)\n* [blog](https://glebbahmutov.com/blog)\n\nLicense: MIT - do anything with the code, but don't blame me if it does not work.\n\nSupport: if you find any problems with this module, email / tweet /\n[open issue](https://github.com/bahmutov/execa-wrap/issues) on Github\n\n## MIT License\n\nCopyright (c) 2017 Gleb Bahmutov \u0026lt;gleb.bahmutov@gmail.com\u0026gt;\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n[npm-icon]: https://nodei.co/npm/execa-wrap.svg?downloads=true\n[npm-url]: https://npmjs.org/package/execa-wrap\n[ci-image]: https://travis-ci.org/bahmutov/execa-wrap.svg?branch=master\n[ci-url]: https://travis-ci.org/bahmutov/execa-wrap\n[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n[semantic-url]: https://github.com/semantic-release/semantic-release\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n[standard-url]: http://standardjs.com/\n[renovate-badge]: https://img.shields.io/badge/renovate-app-blue.svg\n[renovate-app]: https://renovateapp.com/\n[execa]: https://github.com/sindresorhus/execa\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fexeca-wrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbahmutov%2Fexeca-wrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbahmutov%2Fexeca-wrap/lists"}