Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.

Update hasReact conditional (#982)

* Update hasReact conditional

- Prevent error when a dependency key doesn't exist
- Check `optionalDependencies`

* Update index.js

* Update scripts/prepare/index.js

Co-authored-by: Phil Pluckthun <phil@kitten.sh>

Co-authored-by: Phil Pluckthun <phil@kitten.sh>

Changed files
+1 -1
scripts
prepare
+1 -1
scripts/prepare/index.js
···
const cwd = process.cwd();
const workspaceRoot = path.resolve(__dirname, '../../');
const pkg = require(path.resolve(cwd, 'package.json'));
-
const hasReact = !!pkg.dependencies.react || !!pkg.peerDependencies.react;
const normalize = name => name
.replace(/[@\s\/\.]+/g, ' ')
···
const cwd = process.cwd();
const workspaceRoot = path.resolve(__dirname, '../../');
const pkg = require(path.resolve(cwd, 'package.json'));
+
const hasReact = ['dependencies', 'optionalDependencies', 'peerDependencies'].some((dep) => dep in pkg && "react" in pkg[dep]);
const normalize = name => name
.replace(/[@\s\/\.]+/g, ' ')