From e76e33aa6a34c5d4637b95732b26d2500a026ad0 Mon Sep 17 00:00:00 2001 From: Spencer Miskoviak Date: Sun, 23 Jul 2023 12:14:58 -0600 Subject: [PATCH] fix(list-different): respect ignore option --- __tests__/core/list-different.test.ts | 31 ++++++++++++++++++++++++++- lib/core/list-different.ts | 10 ++------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/__tests__/core/list-different.test.ts b/__tests__/core/list-different.test.ts index d4a86a2..312da18 100644 --- a/__tests__/core/list-different.test.ts +++ b/__tests__/core/list-different.test.ts @@ -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(); }); @@ -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`) + ); + }); }); }); diff --git a/lib/core/list-different.ts b/lib/core/list-different.ts index 217129d..2895d4c 100644 --- a/lib/core/list-different.ts +++ b/lib/core/list-different.ts @@ -1,4 +1,3 @@ -import glob from "glob"; import fs from "fs"; import { alerts } from "./alerts"; @@ -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 => { - // 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(