Skip to content

Commit

Permalink
fix: safelist option in CLI
Browse files Browse the repository at this point in the history
fix #513
  • Loading branch information
Ffloriel committed Dec 13, 2020
1 parent 61a04ad commit 43dbe3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/purgecss/__tests__/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("PurgeCSS CLI", () => {
const testFolder = path.resolve(__dirname, "./test_examples/cli/simple/");
it("should print the correct output", async () => {
const response = await asyncExec(
`${purgeCSSExecutable} --content ${testFolder}/src/content.html ${testFolder}/src/*.js --css ${testFolder}/src/style.css`
`${purgeCSSExecutable} --content ${testFolder}/src/content.html ${testFolder}/src/*.js --css ${testFolder}/src/style.css --safelist className`
);
const result = JSON.parse(response.stdout);
expect(result[0].css).toBe(".hello {\n color: red;\n}\n");
Expand Down
4 changes: 3 additions & 1 deletion packages/purgecss/bin/purgecss.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const {
default: PurgeCSS,
defaultOptions,
setOptions,
standardizeSafelist,
} = require("../lib/purgecss");

async function writeCSSToFile(filePath, css) {
Expand Down Expand Up @@ -57,7 +58,8 @@ const run = async () => {
if (program.keyframes) options.keyframes = program.keyframes;
if (program.rejected) options.rejected = program.rejected;
if (program.variables) options.variables = program.variables;
if (program.safelist) options.safelist = program.safelist;
if (program.safelist)
options.safelist = standardizeSafelist(program.safelist);
if (program.blocklist) options.blocklist = program.blocklist;

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

0 comments on commit 43dbe3c

Please sign in to comment.