Skip to content

Commit 6efe58d

Browse files
author
Igor Ganapolsky
committed
fix: allow unmatched ignore globs
1 parent ff767d2 commit 6efe58d

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

‎.changeset/quiet-globs-ignore.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/config": patch
3+
---
4+
5+
Allow unmatched glob patterns in the `ignore` config option.

‎packages/config/src/index.test.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -718,11 +718,9 @@ describe("parser errors", () => {
718718
`);
719719
});
720720
test("ignore package that does not exist (using glob expressions)", () => {
721-
expect(() => unsafeParse({ ignore: ["pkg-*"] }, defaultPackages))
722-
.toThrowErrorMatchingInlineSnapshot(`
723-
"Some errors occurred when validating the changesets config:
724-
The package or glob expression "pkg-*" is specified in the \`ignore\` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch"
725-
`);
721+
expect(unsafeParse({ ignore: ["pkg-*"] }, defaultPackages)).toEqual(
722+
defaults
723+
);
726724
});
727725
test("ignore missing dependent packages", async () => {
728726
expect(() =>

‎packages/config/src/index.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ function getUnmatchedPatterns(
6868
);
6969
}
7070

71+
function getUnmatchedPackageNames(
72+
listOfPackageNamesOrGlob: readonly string[],
73+
pkgNames: readonly string[]
74+
): string[] {
75+
return getUnmatchedPatterns(listOfPackageNamesOrGlob, pkgNames).filter(
76+
(pkgNameOrGlob) => !micromatch.scan(pkgNameOrGlob).isGlob
77+
);
78+
}
79+
7180
const havePackageGroupsCorrectShape = (
7281
pkgGroups: ReadonlyArray<PackageGroup>
7382
) => {
@@ -360,7 +369,7 @@ export let parse = (json: WrittenConfig, packages: Packages): Config => {
360369
);
361370
} else {
362371
messages.push(
363-
...getUnmatchedPatterns(json.ignore, pkgNames).map(
372+
...getUnmatchedPackageNames(json.ignore, pkgNames).map(
364373
(pkgOrGlob) =>
365374
`The package or glob expression "${pkgOrGlob}" is specified in the \`ignore\` option but it is not found in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch`
366375
)

0 commit comments

Comments
 (0)