diff --git a/packages/purgecss/__tests__/cli/cli-file-output.test.ts b/packages/purgecss/__tests__/cli/cli-file-output.test.ts index 5a387b70..6aba63ef 100644 --- a/packages/purgecss/__tests__/cli/cli-file-output.test.ts +++ b/packages/purgecss/__tests__/cli/cli-file-output.test.ts @@ -1,6 +1,6 @@ import { Command } from "commander"; import { promises as asyncFs } from "fs"; -import * as path from 'path'; +import * as path from "path"; import { parseCommandOptions, run } from "../../src/bin"; import { CLI_TEST_FOLDER } from "../utils"; @@ -8,13 +8,13 @@ describe("PurgeCSS CLI file output", () => { const program = parseCommandOptions(new Command()); beforeAll(async () => { - const tempFolder = path.resolve(CLI_TEST_FOLDER, '.temp'); + const tempFolder = path.resolve(CLI_TEST_FOLDER, ".temp"); try { await asyncFs.access(tempFolder); } catch { - await asyncFs.mkdir(tempFolder, { recursive: true }) + await asyncFs.mkdir(tempFolder, { recursive: true }); } - }) + }); it("should output the result into a file if there's one result", async () => { program.parse([ diff --git a/packages/purgecss/__tests__/cli/cli-multiple-files-output.test.ts b/packages/purgecss/__tests__/cli/cli-multiple-files-output.test.ts index e44d30a5..41ac1613 100644 --- a/packages/purgecss/__tests__/cli/cli-multiple-files-output.test.ts +++ b/packages/purgecss/__tests__/cli/cli-multiple-files-output.test.ts @@ -1,6 +1,6 @@ import { Command } from "commander"; import { promises as asyncFs } from "fs"; -import * as path from 'path'; +import * as path from "path"; import { parseCommandOptions, run } from "../../src/bin"; import { CLI_TEST_FOLDER } from "../utils"; @@ -8,13 +8,13 @@ describe("PurgeCSS CLI file output", () => { const program = parseCommandOptions(new Command()); beforeAll(async () => { - const tempFolder = path.resolve(CLI_TEST_FOLDER, '.temp'); + const tempFolder = path.resolve(CLI_TEST_FOLDER, ".temp"); try { await asyncFs.access(tempFolder); } catch { - await asyncFs.mkdir(tempFolder, { recursive: true }) + await asyncFs.mkdir(tempFolder, { recursive: true }); } - }) + }); it("should output the result into a file if there's one result", async () => { program.parse([ diff --git a/packages/purgecss/src/index.ts b/packages/purgecss/src/index.ts index 9a188837..0c8c2ca7 100644 --- a/packages/purgecss/src/index.ts +++ b/packages/purgecss/src/index.ts @@ -18,7 +18,7 @@ import { IGNORE_ANNOTATION_CURRENT, IGNORE_ANNOTATION_END, IGNORE_ANNOTATION_NEXT, - IGNORE_ANNOTATION_START + IGNORE_ANNOTATION_START, } from "./constants"; import ExtractorResultSets from "./ExtractorResultSets"; import { CSS_SAFELIST } from "./internal-safelist"; @@ -36,7 +36,7 @@ import { RawCSS, ResultPurge, UserDefinedOptions, - UserDefinedSafelist + UserDefinedSafelist, } from "./types"; import { matchAll } from "./utils"; import VariablesStructure from "./VariablesStructure"; @@ -323,7 +323,7 @@ class PurgeCSS { private usedFontFaces: Set = new Set(); public selectorsRemoved: Set = new Set(); public removedNodes: postcss.Node[] = []; - private variablesStructure: VariablesStructure = new VariablesStructure(); + public variablesStructure: VariablesStructure = new VariablesStructure(); public options: Options = defaultOptions; @@ -596,8 +596,10 @@ class PurgeCSS { ? option : await asyncFs.readFile(option, "utf-8") : option.raw; - const isFromFile = typeof option === "string" && !this.options.stdin - const root = postcss.parse(cssContent, { from: isFromFile ? option : undefined }); + const isFromFile = typeof option === "string" && !this.options.stdin; + const root = postcss.parse(cssContent, { + from: isFromFile ? option : undefined, + }); // purge unused selectors this.walkThroughCSS(root, selectors); @@ -608,7 +610,10 @@ class PurgeCSS { const postCSSResult = root.toResult({ map: this.options.sourceMap, - to: typeof this.options.sourceMap === 'object' ? this.options.sourceMap.to : undefined + to: + typeof this.options.sourceMap === "object" + ? this.options.sourceMap.to + : undefined, }); const result: ResultPurge = { css: postCSSResult.toString(), @@ -630,7 +635,6 @@ class PurgeCSS { .toString(); } - sources.push(result); } return sources;