Skip to content
Permalink
Browse files

fix(generic): automatically warn w/a nightly package manager version

ISSUES CLOSED: #334
  • Loading branch information
malept committed Sep 25, 2017
1 parent 5a9848c commit d997ba0c9109b2abfc3e02cf1c2a06b8f8a129c6
Showing with 21 additions and 2 deletions.
  1. +6 −1 src/util/check-system.js
  2. +15 −1 test/fast/system_spec.js
@@ -27,10 +27,15 @@ const YARN_WHITELISTED_VERSIONS = {
linux: '0.27.5',
};

export function isNightlyYarnVersion(version) {
return /((?:\d\.?)+)-\d.*/.test(version);
}

function warnIfPackageManagerIsntAKnownGoodVersion(packageManager, version, whitelistedVersions, ora) {
const osVersions = whitelistedVersions[process.platform];
const versions = osVersions ? `${whitelistedVersions.all} || ${osVersions}` : whitelistedVersions.all;
if (!semver.satisfies(version.toString(), versions)) {
const versionString = version.toString();
if (isNightlyYarnVersion(versionString) || !semver.satisfies(versionString, versions)) {
ora.warn(
`You are using ${packageManager}, but not a known good version.\n` +
`The known versions that work with Electron Forge are: ${versions}`
@@ -1,10 +1,24 @@
import { expect } from 'chai';

import checkSystem from '../../src/util/check-system';
import checkSystem, { isNightlyYarnVersion } from '../../src/util/check-system';
import { fakeOra } from '../../src/util/ora';

describe('check-system', () => {
it('should succeed on valid agents', async () => {
expect(await checkSystem(fakeOra())).to.be.equal(true);
});

describe('isNightlyYarnVersion', () => {
it('should not match release versions', () => {
expect(isNightlyYarnVersion('0.10.0')).to.be.equal(false);
});

it('should not match rc/beta/alpha versions', () => {
expect(isNightlyYarnVersion('0.10.0-beta.1')).to.be.equal(false);
});

it('should match nightly versions', () => {
expect(isNightlyYarnVersion('0.23.0-20170311.0515')).to.be.equal(true);
});
});
});

0 comments on commit d997ba0

Please sign in to comment.
You can’t perform that action at this time.