Skip to content

Commit 8b4f5ef

Browse files
committed
refactor: Use anchoredRegex
1 parent 0ce0607 commit 8b4f5ef

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/shell.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ExecOptions, exec as execWithCallback } from 'child_process';
22
import { promisify } from 'util';
33

4-
import { escapeRegex } from './regex';
4+
import { anchoredRegex } from './regex';
55

66
/**
77
* Promisified version of `child_process.exec`.
@@ -192,11 +192,8 @@ sh.mock = () => {
192192
},
193193

194194
command(command: string | RegExp) {
195-
const re = typeof command === 'string'
196-
? new RegExp(`^${escapeRegex(command)}$`)
197-
: command;
198195
const mocks: Mock[] = [];
199-
matchers.push([re, mocks]);
196+
matchers.push([anchoredRegex(command), mocks]);
200197

201198
const cmdController: MockShCommandController = {
202199
returns(mock?: { exitCode?: number, stdout?: string, stderr?: string }) {

0 commit comments

Comments
 (0)