diff --git a/lib/watch/utils.js b/lib/watch/utils.js index dae37507..7605d449 100644 --- a/lib/watch/utils.js +++ b/lib/watch/utils.js @@ -3,11 +3,10 @@ const chalk = require('chalk') const path = require('node:path') +const escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + const arrayToRegExp = (arr) => { - const reg = arr.map((file) => { - if (/^\./.test(file)) { return `\\${file}` } - return file - }).join('|') + const reg = arr.map((file) => escapeRegExp(file)).join('|') return new RegExp(`(${reg})`) }