diff --git a/package-lock.json b/package-lock.json index 1f883cb..69bd323 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,7 @@ "specialist": "^1.4.5", "tiny-editorconfig": "^1.0.0", "tiny-jsonc": "^1.0.1", - "tiny-readdir-glob": "^1.22.24", + "tiny-readdir-glob": "^1.23.0", "tiny-spinner": "^2.0.4", "worktank": "^2.7.3", "zeptomatch": "^2.0.0", @@ -5779,9 +5779,9 @@ } }, "node_modules/tiny-readdir-glob": { - "version": "1.22.24", - "resolved": "https://registry.npmjs.org/tiny-readdir-glob/-/tiny-readdir-glob-1.22.24.tgz", - "integrity": "sha512-HPDNMin7GoyPMesJNkAeT0ERU51ZWFby2RXEE2MHeVeO4c0i07679cuEMKzhKNBlBrBKoVjOmaie5y+FnRwL8g==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/tiny-readdir-glob/-/tiny-readdir-glob-1.23.0.tgz", + "integrity": "sha512-ElwCbSNP9ElOsrxGHieDswd27w/72JyyrlMyFsP/hAA/xEZbt8euWTEunxQ6bapfiCtGW799Ip0I4HnQ+ZPd6g==", "dependencies": { "tiny-readdir": "^2.7.0", "zeptomatch": "^1.2.2", @@ -10580,9 +10580,9 @@ } }, "tiny-readdir-glob": { - "version": "1.22.24", - "resolved": "https://registry.npmjs.org/tiny-readdir-glob/-/tiny-readdir-glob-1.22.24.tgz", - "integrity": "sha512-HPDNMin7GoyPMesJNkAeT0ERU51ZWFby2RXEE2MHeVeO4c0i07679cuEMKzhKNBlBrBKoVjOmaie5y+FnRwL8g==", + "version": "1.23.0", + "resolved": "https://registry.npmjs.org/tiny-readdir-glob/-/tiny-readdir-glob-1.23.0.tgz", + "integrity": "sha512-ElwCbSNP9ElOsrxGHieDswd27w/72JyyrlMyFsP/hAA/xEZbt8euWTEunxQ6bapfiCtGW799Ip0I4HnQ+ZPd6g==", "requires": { "tiny-readdir": "^2.7.0", "zeptomatch": "^1.2.2", diff --git a/package.json b/package.json index 3e8a507..e8992ab 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "specialist": "^1.4.5", "tiny-editorconfig": "^1.0.0", "tiny-jsonc": "^1.0.1", - "tiny-readdir-glob": "^1.22.24", + "tiny-readdir-glob": "^1.23.0", "tiny-spinner": "^2.0.4", "worktank": "^2.7.3", "zeptomatch": "^2.0.0", diff --git a/src/index.ts b/src/index.ts index 11cc15c..b3f8541 100644 --- a/src/index.ts +++ b/src/index.ts @@ -200,7 +200,7 @@ async function runGlobs(options: Options, pluginsDefaultOptions: PluginsOptions, if (!totalMatched && !totalIgnored) { if (options.errorOnUnmatchedPattern) { - stderr.prefixed.error(`No files matching the given patterns were found`); + stderr.prefixed.error(`No files matching the given patterns were found.`); } } diff --git a/src/utils.ts b/src/utils.ts index 135da49..d7cb8f5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -304,7 +304,7 @@ async function normalizeOptions(options: unknown, targets: unknown[]): Promise { + runCli("patterns", ["directory/**/*.js", "other-directory/**/*.js", "-l"]).test({ + status: 1, + }); +}); + +describe("multiple patterns with an extra non-existent pattern", () => { + runCli("patterns", ["directory/**/*.js", "non-existent.js", "-l"]).test({ + status: 1, + }); +}); + +describe("multiple patterns with a negated pattern", () => { + runCli("patterns", ["**/*.js", "!**/nested-directory/**", "-l"]).test({ + status: 1, + }); +}); + +describe("multiple patterns with a negated pattern, ignores node_modules by default", () => { + runCli("patterns", ["**/*.js", "!directory/**", "-l"]).test({ + status: 1, + }); +}); + +// TODO: Handle leading `./` and `../` in patterns. +describe.skip("multiple patterns with a negated pattern and leading `./`, ignores node_modules by default", () => { + runCli("patterns", ["./**/*.js", "!./directory/**", "-l"]).test({ + status: 1, + }); +}); + +describe("multiple patterns with a negated pattern, doesn't ignore node_modules with the --with-node-modules flag", () => { + runCli("patterns", ["**/*.js", "!directory/**", "-l", "--with-node-modules"]).test({ + status: 1, + }); +}); + +describe("exits with an informative message when there are no patterns provided", () => { + runCli("patterns").test({ + status: 1, + }); +}); + +describe("multiple patterns, throws an error and exits with a non-zero code when there are no matches", () => { + runCli("patterns", ["non-existent.js", "other-non-existent.js", "-l"]).test({ + status: 1, + }); +}); + +describe("file names with special characters", () => { + runCli("patterns-special-characters/square-brackets/", ["[with-square-brackets].js", "-l"]).test({ + status: 1, + write: [], + stderr: "", + stdout: "[with-square-brackets].js", + }); + runCli("patterns-special-characters/dots/", ["[...with-square-brackets-and-dots].js", "-l"]).test({ + status: 1, + write: [], + stderr: "", + stdout: "[...with-square-brackets-and-dots].js", + }); +});