Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Underscore #20

Merged
merged 1 commit into from
Jan 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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