Skip to content

Commit

Permalink
Ignore linux for version range checks. (#2186)
Browse files Browse the repository at this point in the history
* Ignore linux for version range checks.

* Don't access null variable. Return null on render if variable is null.
  • Loading branch information
BrianAllred authored and MarshallOfSound committed Feb 12, 2017
1 parent 0193de4 commit 0598b95
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/renderer/ui/components/generic/PlatformSpecific.js
Expand Up @@ -3,7 +3,7 @@ import os from 'os';
import semver from 'semver';

const parsedOSVersion = semver.parse(os.release());
const osVersion = `${parsedOSVersion.major}.${parsedOSVersion.minor}.${parsedOSVersion.patch}`;
const osVersion = parsedOSVersion ? `${parsedOSVersion.major}.${parsedOSVersion.minor}.${parsedOSVersion.patch}` : null;

export const semverValidator = (props, propName, componentName) => {
if (props[propName]) {
Expand All @@ -23,6 +23,10 @@ export default class PlatformSpecific extends Component {
if (process.platform === this.props.platform) {
if (!this.props.versionRange) return this.props.children;

if (osVersion === null) {
return null;
}

if (semver.validRange(this.props.versionRange) && semver.satisfies(osVersion, this.props.versionRange)) {
return this.props.children;
}
Expand Down

0 comments on commit 0598b95

Please sign in to comment.