Skip to content

Commit

Permalink
Merge pull request #20 from klaussner/remove-underscore
Browse files Browse the repository at this point in the history
Remove Underscore
  • Loading branch information
Tom Coleman authored Jan 16, 2018
2 parents f50c986 + 6ec34ff commit a6b7bc4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions check-npm-versions.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import semver from 'semver';
import { _ } from 'meteor/underscore';

// Returns:
// - true if a version of the package in the range is installed
// - false if no version is installed
// - version# if incompatible version is installed
const compatibleVersionIsInstalled = (name, range) => {
try {
const installedVersion = require(`${name}/package.json`).version;
const installedVersion = require(`${name}/package.json`).version;
if (semver.satisfies(installedVersion, range)) {
return true;
} else {
Expand All @@ -27,19 +26,24 @@ const compatibleVersionIsInstalled = (name, range) => {

export const checkNpmVersions = (packages, packageName) => {
const failures = {};
_.forEach(packages, (range, name) => {

Object.keys(packages).forEach((name) => {
const range = packages[name];
const failure = compatibleVersionIsInstalled(name, range);

if (failure !== true) {
failures[name] = failure;
}
});

if (_.keys(failures).length === 0) {
if (Object.keys(failures).length === 0) {
return true;
}

const errors = [];
_.forEach(failures, (installed, name) => {

Object.keys(failures).forEach((name) => {
const installed = failures[name];
const requirement = `${name}@${packages[name]}`;

if (installed) {
Expand Down

0 comments on commit a6b7bc4

Please sign in to comment.