Skip to content

Commit

Permalink
refactor: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Ffloriel committed Feb 23, 2022
1 parent b72de77 commit 7009294
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
8 changes: 4 additions & 4 deletions packages/purgecss/__tests__/cli/cli-file-output.test.ts
@@ -1,20 +1,20 @@
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";

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([
Expand Down
@@ -1,20 +1,20 @@
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";

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([
Expand Down
18 changes: 11 additions & 7 deletions packages/purgecss/src/index.ts
Expand Up @@ -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";
Expand All @@ -36,7 +36,7 @@ import {
RawCSS,
ResultPurge,
UserDefinedOptions,
UserDefinedSafelist
UserDefinedSafelist,
} from "./types";
import { matchAll } from "./utils";
import VariablesStructure from "./VariablesStructure";
Expand Down Expand Up @@ -323,7 +323,7 @@ class PurgeCSS {
private usedFontFaces: Set<string> = new Set();
public selectorsRemoved: Set<string> = new Set();
public removedNodes: postcss.Node[] = [];
private variablesStructure: VariablesStructure = new VariablesStructure();
public variablesStructure: VariablesStructure = new VariablesStructure();

public options: Options = defaultOptions;

Expand Down Expand Up @@ -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);
Expand All @@ -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(),
Expand All @@ -630,7 +635,6 @@ class PurgeCSS {
.toString();
}


sources.push(result);
}
return sources;
Expand Down

0 comments on commit 7009294

Please sign in to comment.