Skip to content

Commit 43dbe3c

Browse files
committed
fix: safelist option in CLI
fix #513
1 parent 61a04ad commit 43dbe3c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/purgecss/__tests__/cli.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("PurgeCSS CLI", () => {
99
const testFolder = path.resolve(__dirname, "./test_examples/cli/simple/");
1010
it("should print the correct output", async () => {
1111
const response = await asyncExec(
12-
`${purgeCSSExecutable} --content ${testFolder}/src/content.html ${testFolder}/src/*.js --css ${testFolder}/src/style.css`
12+
`${purgeCSSExecutable} --content ${testFolder}/src/content.html ${testFolder}/src/*.js --css ${testFolder}/src/style.css --safelist className`
1313
);
1414
const result = JSON.parse(response.stdout);
1515
expect(result[0].css).toBe(".hello {\n color: red;\n}\n");

packages/purgecss/bin/purgecss.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {
55
default: PurgeCSS,
66
defaultOptions,
77
setOptions,
8+
standardizeSafelist,
89
} = require("../lib/purgecss");
910

1011
async function writeCSSToFile(filePath, css) {
@@ -57,7 +58,8 @@ const run = async () => {
5758
if (program.keyframes) options.keyframes = program.keyframes;
5859
if (program.rejected) options.rejected = program.rejected;
5960
if (program.variables) options.variables = program.variables;
60-
if (program.safelist) options.safelist = program.safelist;
61+
if (program.safelist)
62+
options.safelist = standardizeSafelist(program.safelist);
6163
if (program.blocklist) options.blocklist = program.blocklist;
6264

6365
const purged = await new PurgeCSS().purge(options);

0 commit comments

Comments
 (0)