Skip to content

Commit

Permalink
fix(list-different): respect ignore option
Browse files Browse the repository at this point in the history
  • Loading branch information
skovy committed Jul 23, 2023
1 parent f83b423 commit e76e33a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
31 changes: 30 additions & 1 deletion __tests__/core/list-different.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ describeAllImplementations((implementation) => {
outputFolder: null,
});

expect(console.log).not.toHaveBeenCalled();
expect(console.log).toHaveBeenCalledTimes(1);
expect(console.log).toBeCalledWith(
expect.stringContaining(`Only 1 file found for`)
);
expect(exit).not.toHaveBeenCalled();
});

Expand Down Expand Up @@ -126,5 +129,31 @@ describeAllImplementations((implementation) => {
expect.stringContaining(`no-generated.scss`)
);
});

test("ignores ignored files", async () => {
const pattern = `${__dirname}/list-different/no-generated.scss`;

await listDifferent(pattern, {
banner: "",
watch: false,
ignoreInitial: false,
exportType: "named",
exportTypeName: "ClassNames",
exportTypeInterface: "Styles",
listDifferent: true,
ignore: ["**/no-generated.scss"],
implementation,
quoteType: "single",
updateStaleOnly: false,
logLevel: "verbose",
outputFolder: null,
});

expect(exit).not.toHaveBeenCalled();
expect(console.log).toHaveBeenCalledTimes(1);
expect(console.log).toBeCalledWith(
expect.stringContaining(`No files found`)
);
});
});
});
10 changes: 2 additions & 8 deletions lib/core/list-different.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import glob from "glob";
import fs from "fs";

import { alerts } from "./alerts";
Expand All @@ -8,18 +7,13 @@ import {
classNamesToTypeDefinitions,
getTypeDefinitionPath,
} from "../typescript";
import { listFilesAndPerformSanityChecks } from "./list-files-and-perform-sanity-checks";

export const listDifferent = async (
pattern: string,
options: ConfigOptions
): Promise<void> => {
// Find all the files that match the provided pattern.
const files = glob.sync(pattern);

if (!files || !files.length) {
alerts.notice("No files found.");
return;
}
const files = listFilesAndPerformSanityChecks(pattern, options);

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

0 comments on commit e76e33a

Please sign in to comment.