Skip to content

Commit e76e33a

Browse files
committed
fix(list-different): respect ignore option
1 parent f83b423 commit e76e33a

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

__tests__/core/list-different.test.ts

+30-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ describeAllImplementations((implementation) => {
7070
outputFolder: null,
7171
});
7272

73-
expect(console.log).not.toHaveBeenCalled();
73+
expect(console.log).toHaveBeenCalledTimes(1);
74+
expect(console.log).toBeCalledWith(
75+
expect.stringContaining(`Only 1 file found for`)
76+
);
7477
expect(exit).not.toHaveBeenCalled();
7578
});
7679

@@ -126,5 +129,31 @@ describeAllImplementations((implementation) => {
126129
expect.stringContaining(`no-generated.scss`)
127130
);
128131
});
132+
133+
test("ignores ignored files", async () => {
134+
const pattern = `${__dirname}/list-different/no-generated.scss`;
135+
136+
await listDifferent(pattern, {
137+
banner: "",
138+
watch: false,
139+
ignoreInitial: false,
140+
exportType: "named",
141+
exportTypeName: "ClassNames",
142+
exportTypeInterface: "Styles",
143+
listDifferent: true,
144+
ignore: ["**/no-generated.scss"],
145+
implementation,
146+
quoteType: "single",
147+
updateStaleOnly: false,
148+
logLevel: "verbose",
149+
outputFolder: null,
150+
});
151+
152+
expect(exit).not.toHaveBeenCalled();
153+
expect(console.log).toHaveBeenCalledTimes(1);
154+
expect(console.log).toBeCalledWith(
155+
expect.stringContaining(`No files found`)
156+
);
157+
});
129158
});
130159
});

lib/core/list-different.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import glob from "glob";
21
import fs from "fs";
32

43
import { alerts } from "./alerts";
@@ -8,18 +7,13 @@ import {
87
classNamesToTypeDefinitions,
98
getTypeDefinitionPath,
109
} from "../typescript";
10+
import { listFilesAndPerformSanityChecks } from "./list-files-and-perform-sanity-checks";
1111

1212
export const listDifferent = async (
1313
pattern: string,
1414
options: ConfigOptions
1515
): Promise<void> => {
16-
// Find all the files that match the provided pattern.
17-
const files = glob.sync(pattern);
18-
19-
if (!files || !files.length) {
20-
alerts.notice("No files found.");
21-
return;
22-
}
16+
const files = listFilesAndPerformSanityChecks(pattern, options);
2317

2418
// Wait for all the files to be checked.
2519
await Promise.all(files.map((file) => checkFile(file, options))).then(

0 commit comments

Comments
 (0)