diff --git a/Jakefile.js b/Jakefile.js
index cf7f69d41dc..d46c2437ccb 100644
--- a/Jakefile.js
+++ b/Jakefile.js
@@ -131,7 +131,7 @@ var languageServiceLibrarySources = [
var harnessCoreSources = [
"harness.ts",
- "vfs.ts",
+ "virtualFileSystem.ts",
"sourceMapRecorder.ts",
"harnessLanguageService.ts",
"fourslash.ts",
@@ -163,7 +163,7 @@ var harnessSources = harnessCoreSources.concat([
"cachingInServerLSHost.ts",
"moduleResolution.ts",
"tsconfigParsing.ts",
- "expandFiles.ts"
+ "matchFiles.ts"
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([
diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts
index a5cd7abc505..6935cf28bcd 100644
--- a/src/compiler/commandLineParser.ts
+++ b/src/compiler/commandLineParser.ts
@@ -582,9 +582,61 @@ namespace ts {
return { options, errors };
}
+ /**
+ * Tests for a path that ends in a recursive directory wildcard.
+ * Matches **, /**, /**\/, and /**\/, but not a**b.
+ *
+ * NOTE: used \/ in place of / above to avoid ending the comment.
+ *
+ * Breakdown:
+ * (^|\/) # matches either the beginning of the string or a directory separator.
+ * \*\* # matches the recursive directory wildcard "**".
+ * \/?$ # matches an optional trailing directory separator at the end of the string.
+ */
const invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
+
+ /**
+ * Tests for a path with multiple recursive directory wildcards.
+ * Matches **\/** and **\/a/**, but not **\/a**b.
+ *
+ * NOTE: used \/ in place of / above to avoid ending the comment.
+ *
+ * Breakdown:
+ * (^|\/) # matches either the beginning of the string or a directory separator.
+ * \*\*\/ # matches a recursive directory wildcard "**" followed by a directory separator.
+ * (.*\/)? # optionally matches any number of characters followed by a directory separator.
+ * \*\* # matches a recursive directory wildcard "**"
+ * ($|\/) # matches either the end of the string or a directory separator.
+ */
const invalidMultipleRecursionPatterns = /(^|\/)\*\*\/(.*\/)?\*\*($|\/)/;
+ /**
+ * Tests for a path containing a wildcard character in a directory component of the path.
+ * Matches /*\/, /?/, and /a*b/, but not /a/ or /a/*.
+ *
+ * NOTE: used \/ in place of / above to avoid ending the comment.
+ *
+ * Breakdown:
+ * \/ # matches a directory separator.
+ * [^/]*? # matches any number of characters excluding directory separators (non-greedy).
+ * [*?] # matches either a wildcard character (* or ?)
+ * [^/]* # matches any number of characters excluding directory separators (greedy).
+ * \/ # matches a directory separator.
+ */
+ const watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
+
+ /**
+ * Matches the portion of a wildcard path that does not contain wildcards.
+ * Matches /a of /a/*, or /a/b/c of /a/b/c/?/d.
+ *
+ * Breakdown:
+ * ^ # matches the beginning of the string
+ * [^*?]* # matches any number of non-wildcard characters
+ * (?=\/[^/]*[*?]) # lookahead that matches a directory separator followed by
+ * # a path component that contains at least one wildcard character (* or ?).
+ */
+ const wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
+
/**
* Expands an array of file specifications.
*
@@ -693,9 +745,6 @@ namespace ts {
return validSpecs;
}
- const watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
- const wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
-
/**
* Gets directories in a set of include patterns that should be watched for changes.
*/
diff --git a/src/harness/harness.ts b/src/harness/harness.ts
index 509c193666f..f33cafc456d 100644
--- a/src/harness/harness.ts
+++ b/src/harness/harness.ts
@@ -23,7 +23,7 @@
///
///
///
-///
+///
/* tslint:disable:no-null */
// Block scoped definitions work poorly for global variables, temporarily enable var
diff --git a/src/harness/vfs.ts b/src/harness/virtualFileSystem.ts
similarity index 100%
rename from src/harness/vfs.ts
rename to src/harness/virtualFileSystem.ts
diff --git a/tests/cases/unittests/expandFiles.ts b/tests/cases/unittests/matchFiles.ts
similarity index 97%
rename from tests/cases/unittests/expandFiles.ts
rename to tests/cases/unittests/matchFiles.ts
index bbda14a2cfa..faccd31b88f 100644
--- a/tests/cases/unittests/expandFiles.ts
+++ b/tests/cases/unittests/matchFiles.ts
@@ -1,5 +1,6 @@
///
///
+///
namespace ts {
class MockParseConfigHost extends Utils.VirtualFileSystem implements ParseConfigHost {
@@ -89,7 +90,7 @@ namespace ts {
"c:/dev/f.other"
]);
- describe("expandFiles", () => {
+ describe("matchFiles", () => {
describe("with literal file list", () => {
it("without exclusions", () => {
const json = {