Skip to content

Commit

Permalink
fix(generic): automatically warn w/a nightly package manager version
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #334
  • Loading branch information
malept committed Sep 26, 2017
1 parent 5a9848c commit d997ba0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/util/check-system.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
Expand Down
16 changes: 15 additions & 1 deletion test/fast/system_spec.js
Original file line number Diff line number Diff line change
@@ -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.