MCPcopy Index your code
hub / github.com/dmno-dev/bumpy / installShellMock

Function installShellMock

packages/bumpy/test/helpers-shell-mock.ts:50–73  ·  view source on GitHub ↗
(opts: { interceptGh?: boolean } = {})

Source from the content-addressed store, hash-verified

48 * By default intercepts all `gh` commands. Real git/system commands pass through.
49 */
50export function installShellMock(opts: { interceptGh?: boolean } = {}) {
51 calls = [];
52 rules = [];
53
54 const interceptGh = opts.interceptGh ?? true;
55 if (interceptGh) {
56 rules.push({ match: 'gh --version', response: 'gh version 2.50.0' });
57 rules.push({ match: /^gh /, response: '{}' });
58 }
59
60 _setInterceptor((args, opts) => {
61 const cmdString = args.join(' ');
62 calls.push({ command: cmdString, args: [...args], opts });
63
64 const rule = findRule(cmdString);
65 if (rule) {
66 if (rule.error) return { intercepted: true, error: rule.error };
67 return { intercepted: true, result: rule.response ?? '' };
68 }
69
70 // Not intercepted — pass through to real implementation
71 return { intercepted: false };
72 });
73}
74
75/** Reset mock state (calls + rules) and re-install with fresh defaults */
76export function resetMockState(opts: { interceptGh?: boolean } = {}) {

Callers 6

changelog.test.tsFile · 0.90
ci-comment.test.tsFile · 0.90
resetMockStateFunction · 0.85

Calls 2

_setInterceptorFunction · 0.90
findRuleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…