Skip to content

Commit 520772b

Browse files
authored
bugfix: Only throw No files found from the passed PurgeCSS option 'content'. warning when files/globs are passed to content (FullHuman#1188)
* add failing test * only warn when file content is passed
1 parent 4ee5ad8 commit 520772b

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

packages/purgecss/__tests__/index.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,15 @@ describe("Warn if no files are found from the option 'content'", () => {
117117
console.warn = originalConsoleWarn;
118118
});
119119

120+
it("does not warn if raw content is found", async () => {
121+
const originalConsoleWarn = console.warn;
122+
console.warn = jest.fn();
123+
await new PurgeCSS().purge({
124+
content: [{ raw: '<div class="a">test</div>', extension: 'html' }],
125+
css: [`${ROOT_TEST_EXAMPLES}others/remove_unused.css`]
126+
});
127+
expect(console.warn).not.toHaveBeenCalled();
128+
console.warn = originalConsoleWarn;
129+
});
130+
120131
})

packages/purgecss/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ class PurgeCSS {
427427
}));
428428
}
429429
}
430-
if (filesNames.length === 0) {
430+
if (files.length > 0 && filesNames.length === 0) {
431431
console.warn("No files found from the passed PurgeCSS option 'content'.")
432432
}
433433
for (const file of filesNames) {

0 commit comments

Comments
 (0)