@@ -582,9 +582,61 @@ namespace ts {
582582 return { options, errors } ;
583583 }
584584
585+ /**
586+ * Tests for a path that ends in a recursive directory wildcard.
587+ * Matches **, /**, /**\/, and /**\/, but not a**b.
588+ *
589+ * NOTE: used \/ in place of / above to avoid ending the comment.
590+ *
591+ * Breakdown:
592+ * (^|\/) # matches either the beginning of the string or a directory separator.
593+ * \*\* # matches the recursive directory wildcard "**".
594+ * \/?$ # matches an optional trailing directory separator at the end of the string.
595+ */
585596 const invalidTrailingRecursionPattern = / ( ^ | \/ ) \* \* \/ ? $ / ;
597+
598+ /**
599+ * Tests for a path with multiple recursive directory wildcards.
600+ * Matches **\/** and **\/a/**, but not **\/a**b.
601+ *
602+ * NOTE: used \/ in place of / above to avoid ending the comment.
603+ *
604+ * Breakdown:
605+ * (^|\/) # matches either the beginning of the string or a directory separator.
606+ * \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator.
607+ * (.*\/)? # optionally matches any number of characters followed by a directory separator.
608+ * \*\* # matches a recursive directory wildcard "**"
609+ * ($|\/) # matches either the end of the string or a directory separator.
610+ */
586611 const invalidMultipleRecursionPatterns = / ( ^ | \/ ) \* \* \/ ( .* \/ ) ? \* \* ( $ | \/ ) / ;
587612
613+ /**
614+ * Tests for a path containing a wildcard character in a directory component of the path.
615+ * Matches /*\/, /?/, and /a*b/, but not /a/ or /a/*.
616+ *
617+ * NOTE: used \/ in place of / above to avoid ending the comment.
618+ *
619+ * Breakdown:
620+ * \/ # matches a directory separator.
621+ * [^/]*? # matches any number of characters excluding directory separators (non-greedy).
622+ * [*?] # matches either a wildcard character (* or ?)
623+ * [^/]* # matches any number of characters excluding directory separators (greedy).
624+ * \/ # matches a directory separator.
625+ */
626+ const watchRecursivePattern = / \/ [ ^ / ] * ?[ * ? ] [ ^ / ] * \/ / ;
627+
628+ /**
629+ * Matches the portion of a wildcard path that does not contain wildcards.
630+ * Matches /a of /a/*, or /a/b/c of /a/b/c/?/d.
631+ *
632+ * Breakdown:
633+ * ^ # matches the beginning of the string
634+ * [^*?]* # matches any number of non-wildcard characters
635+ * (?=\/[^/]*[*?]) # lookahead that matches a directory separator followed by
636+ * # a path component that contains at least one wildcard character (* or ?).
637+ */
638+ const wildcardDirectoryPattern = / ^ [ ^ * ? ] * (? = \/ [ ^ / ] * [ * ? ] ) / ;
639+
588640 /**
589641 * Expands an array of file specifications.
590642 *
@@ -693,9 +745,6 @@ namespace ts {
693745 return validSpecs ;
694746 }
695747
696- const watchRecursivePattern = / \/ [ ^ / ] * ?[ * ? ] [ ^ / ] * \/ / ;
697- const wildcardDirectoryPattern = / ^ [ ^ * ? ] * (? = \/ [ ^ / ] * [ * ? ] ) / ;
698-
699748 /**
700749 * Gets directories in a set of include patterns that should be watched for changes.
701750 */
0 commit comments