Skip to content
Permalink
Browse files

fix(generic): clean up package manager warning output

Integrate ora into the check system calls.
Break up the package manager warning with a newline.
  • Loading branch information
malept committed Aug 24, 2017
1 parent 88b92fc commit 894ed0a9ddfbac840b2d63fd9d3103ca0403b788
Showing with 14 additions and 14 deletions.
  1. +2 −2 src/electron-forge.js
  2. +10 −11 src/util/check-system.js
  3. +2 −1 test/fast/system_spec.js
@@ -57,8 +57,8 @@ tab.start();
if (process.argv[2] !== 'completion') {
(async () => {
let goodSystem;
await asyncOra('Checking your system', async () => {
goodSystem = await checkSystem();
await asyncOra('Checking your system', async (ora) => {
goodSystem = await checkSystem(ora);
});

if (!goodSystem) {
@@ -1,5 +1,4 @@
import { exec } from 'child_process';
import logSymbols from 'log-symbols';
import semver from 'semver';

import { hasYarn, yarnOrNpmSpawn } from './yarn-or-npm';
@@ -26,31 +25,31 @@ const YARN_WHITELISTED_VERSIONS = {
linux: '0.27.5',
};

function warnIfPackageManagerIsntAKnownGoodVersion(packageManager, version, whitelistedVersions) {
function warnIfPackageManagerIsntAKnownGoodVersion(packageManager, version, whitelistedVersions, ora) {
const osVersions = whitelistedVersions[process.platform];
const versions = osVersions ? `${whitelistedVersions.all} || ${osVersions}` : whitelistedVersions.all;
if (!semver.satisfies(version, versions)) {
console.warn(
logSymbols.warning,
(`You are using ${packageManager}, but not a known good version. The known ` +
`versions that work with Electron Forge are: ${versions}`).yellow
ora.warn(
`You are using ${packageManager}, but not a known good version.\n` +
`The known versions that work with Electron Forge are: ${versions}`
);
}
}

async function checkPackageManagerVersion() {
async function checkPackageManagerVersion(ora) {
return yarnOrNpmSpawn(['--version'])
.then((version) => {
if (hasYarn()) {
warnIfPackageManagerIsntAKnownGoodVersion('Yarn', version, YARN_WHITELISTED_VERSIONS);
warnIfPackageManagerIsntAKnownGoodVersion('Yarn', version, YARN_WHITELISTED_VERSIONS, ora);
} else {
warnIfPackageManagerIsntAKnownGoodVersion('NPM', version, NPM_WHITELISTED_VERSIONS);
warnIfPackageManagerIsntAKnownGoodVersion('NPM', version, NPM_WHITELISTED_VERSIONS, ora);
}

return true;
});
}

export default async () =>
(await Promise.all([checkGitExists(), checkNodeVersion(), checkPackageManagerVersion()]))
export default async function (ora) {
return (await Promise.all([checkGitExists(ora), checkNodeVersion(ora), checkPackageManagerVersion(ora)]))
.every(check => check);
}
@@ -1,9 +1,10 @@
import { expect } from 'chai';

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

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

0 comments on commit 894ed0a

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