Skip to content

Commit

Permalink
perf(styles): do not call path.join twice
Browse files Browse the repository at this point in the history
improved codecov, shortened test env variable name
  • Loading branch information
Anidetrix committed Mar 13, 2020
1 parent 511ea8d commit 272bb8b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default {
],
plugins: [
json(),
replace({ "process.env.ROLLUP_POSTCSS_TEST": false }),
replace({ "process.env.STYLES_TEST": false }),
resolve({
preferBuiltins: true,
extensions: [".ts", ".mjs", ".js", ".json"],
Expand Down
6 changes: 2 additions & 4 deletions src/loaders/postcss/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const loader: Loader<PostCSSLoaderOptions> = {
...postcssModules({
// Skip hash while testing since CSS content would differ on Windows and Linux
// due to different line endings.
generateScopedName: process.env.ROLLUP_POSTCSS_TEST
generateScopedName: process.env.STYLES_TEST
? "[name]_[local]"
: "[name]_[local]__[hash:8]",
failOnWrongOrder: true,
Expand Down Expand Up @@ -195,9 +195,7 @@ const loader: Loader<PostCSSLoaderOptions> = {
const injectorName = safeId("injector");
const injectorPath = normalizePath(
await resolveAsync("./inject-css", {
basedir: process.env.ROLLUP_POSTCSS_TEST
? path.join(process.cwd(), "runtime")
: path.join(__dirname, "runtime"),
basedir: path.join(process.env.STYLES_TEST ? process.cwd() : __dirname, "runtime"),
}),
);
const injectorData =
Expand Down
2 changes: 1 addition & 1 deletion src/loaders/sass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const loader: Loader<SASSLoaderOptions> = {

let fiber: FiberConstructor | undefined;
// Disable `fibers` for testing, it doesn't work
if (sassType == "sass" && !process.env.ROLLUP_POSTCSS_TEST) fiber = loadModule("fibers");
if (sassType == "sass" && !process.env.STYLES_TEST) fiber = loadModule("fibers");

return workQueue.add<Payload>(
async (): Promise<Payload> => {
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import commonjs from "@rollup/plugin-commonjs";
import postcss from "../src";
import { Options } from "../src/types";

process.env.ROLLUP_POSTCSS_TEST = "true";
process.env.STYLES_TEST = "true";

// Types
interface WriteData {
Expand Down

0 comments on commit 272bb8b

Please sign in to comment.