We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
anchoredRegex
1 parent 0ce0607 commit 8b4f5efCopy full SHA for 8b4f5ef
1 file changed
src/shell.ts
@@ -1,7 +1,7 @@
1
import { ExecOptions, exec as execWithCallback } from 'child_process';
2
import { promisify } from 'util';
3
4
-import { escapeRegex } from './regex';
+import { anchoredRegex } from './regex';
5
6
/**
7
* Promisified version of `child_process.exec`.
@@ -192,11 +192,8 @@ sh.mock = () => {
192
},
193
194
command(command: string | RegExp) {
195
- const re = typeof command === 'string'
196
- ? new RegExp(`^${escapeRegex(command)}$`)
197
- : command;
198
const mocks: Mock[] = [];
199
- matchers.push([re, mocks]);
+ matchers.push([anchoredRegex(command), mocks]);
200
201
const cmdController: MockShCommandController = {
202
returns(mock?: { exitCode?: number, stdout?: string, stderr?: string }) {
0 commit comments