{"id":16349343,"url":"https://github.com/stevemao/mock-bin","last_synced_at":"2025-09-24T22:31:31.911Z","repository":{"id":57300019,"uuid":"58251909","full_name":"stevemao/mock-bin","owner":"stevemao","description":"Mock any executable binary","archived":false,"fork":false,"pushed_at":"2017-12-18T05:58:02.000Z","size":20,"stargazers_count":12,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-13T20:52:28.476Z","etag":null,"topics":["bin","binary","mock","mocking","shebang","test","testing","testing-tools","tests"],"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/stevemao.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":"2016-05-07T06:02:57.000Z","updated_at":"2022-12-01T03:56:22.000Z","dependencies_parsed_at":"2022-09-01T08:40:56.973Z","dependency_job_id":null,"html_url":"https://github.com/stevemao/mock-bin","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevemao%2Fmock-bin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevemao%2Fmock-bin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevemao%2Fmock-bin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevemao%2Fmock-bin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevemao","download_url":"https://codeload.github.com/stevemao/mock-bin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234134850,"owners_count":18784885,"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":["bin","binary","mock","mocking","shebang","test","testing","testing-tools","tests"],"created_at":"2024-10-11T00:59:11.340Z","updated_at":"2025-09-24T22:31:26.647Z","avatar_url":"https://github.com/stevemao.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mock-bin [![Build Status: Linux](https://travis-ci.org/stevemao/mock-bin.svg?branch=master)](https://travis-ci.org/stevemao/mock-bin) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/76bg3fbqo2ox9s11/branch/master?svg=true)](https://ci.appveyor.com/project/stevemao/mock-bin/branch/master)\n\n\u003e Mock any executable binary\n\nUseful for mocking tests that run executable binary, especially to fake edge cases and increase test coverage.\n\n\n## Install\n\n```\n$ npm install --save-dev mock-bin\n```\n\n\n## Usage\n\n```js\nconst mockBin = require('mock-bin');\nconst log = 'mocking git!';\nconst unmock = await mockBin('git', 'node', `console.log('${log}')`);\nlet actual = shell.exec('git').stdout;\nt.is(log + '\\n', actual);\n\nunmock();\nactual = shell.exec('git').stdout;\nt.not(log + '\\n', actual);\n```\n\n\n## API\n\n### mockBin(bin, shebang, code)\n\nReturns a promise which resolves with an `unmock()` function.\n\n#### bin\n\nType: `string`\n\nEG: `'git'`.\n\n#### shebang\n\nType: `string`\n\nShebang or environment\n\nEG: `'#!/usr/bin/env node'` or `'bash'`\n\n##### code\n\nType: `string`  \n\nThe actual code you want to execute.\n\n\n## Related\n\n- [mock-git](https://github.com/stevemao/mock-git) - Mock any git command\n\n\n## License\n\nMIT © [Steve Mao](https://github.com/stevemao)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevemao%2Fmock-bin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevemao%2Fmock-bin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevemao%2Fmock-bin/lists"}