@@ -582,9 +582,61 @@ namespace ts {
582
582
return { options, errors } ;
583
583
}
584
584
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
+ */
585
596
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
+ */
586
611
const invalidMultipleRecursionPatterns = / ( ^ | \/ ) \* \* \/ ( .* \/ ) ? \* \* ( $ | \/ ) / ;
587
612
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
+
588
640
/**
589
641
* Expands an array of file specifications.
590
642
*
@@ -693,9 +745,6 @@ namespace ts {
693
745
return validSpecs ;
694
746
}
695
747
696
- const watchRecursivePattern = / \/ [ ^ / ] * ?[ * ? ] [ ^ / ] * \/ / ;
697
- const wildcardDirectoryPattern = / ^ [ ^ * ? ] * (? = \/ [ ^ / ] * [ * ? ] ) / ;
698
-
699
748
/**
700
749
* Gets directories in a set of include patterns that should be watched for changes.
701
750
*/
0 commit comments