Skip to content

Commit

Permalink
fix env check on prod
Browse files Browse the repository at this point in the history
  • Loading branch information
chaance committed Feb 15, 2020
1 parent 3f889be commit 1e0fd2d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/utils/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,22 @@ let checkedPkgs: { [key: string]: boolean } = {};
// @ts-ignore
let checkStyles = (packageName: string): void => void packageName;

// In CJS files, process.env.NODE_ENV is stripped from our build, but we need it
// to prevent style checks from clogging up user logs while testing.
// This is a workaround until we can tweak the build a bit to accommodate.
let { env = { NODE_ENV: "production" } } = process || {};
let nodeEnv = env.NODE_ENV;

if (__DEV__) {
// In CJS files, process.env.NODE_ENV is stripped from our build, but we need
// it to prevent style checks from clogging up user logs while testing.
// This is a workaround until we can tweak the build a bit to accommodate.
let { env } =
typeof process !== "undefined"
? process
: { env: { NODE_ENV: "development" } };

checkStyles = (packageName: string) => {
// only check once per package
if (checkedPkgs[packageName]) return;
checkedPkgs[packageName] = true;

if (
nodeEnv !== "test" &&
env.NODE_ENV !== "test" &&
parseInt(
window
.getComputedStyle(document.body)
Expand Down

0 comments on commit 1e0fd2d

Please sign in to comment.