Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
mout.object.forOwn(pkgMeta[jsonKey], function (value, key) {
var resolved;
var fetching;
var compatible;
var childDecEndpoint = endpointParser.json2decomposed(key, value);
// Check if a compatible one is already resolved
// If there's one, we don't need to resolve it twice
resolved = this._resolved[key];
if (resolved) {
// Find if there's one with the exact same target
compatible = mout.array.find(resolved, function (resolved) {
return childDecEndpoint.target === resolved.target;
}, this);
// If we found one, merge stuff instead of adding as resolved
if (compatible) {
decEndpoint.dependencies[key] = compatible;
compatible.dependants.push(decEndpoint);
compatible.dependants = this._uniquify(compatible.dependants);
return;
}
// Find one that is compatible
compatible = mout.array.find(resolved, function (resolved) {
return this._areCompatible(childDecEndpoint, resolved);
}, this);
.then(function () {
var message;
var data;
var dependantsNames;
var dependants = [];
// Walk the down the tree, gathering dependants of the package
that.walkTree(tree, function (node, nodeName) {
if (name === nodeName) {
dependants.push.apply(dependants, mout.object.values(node.dependants));
}
}, true);
// Remove duplicates
dependants = mout.array.unique(dependants);
// Note that the root is filtered from the dependants
// as well as other dependants marked to be uninstalled
dependants = dependants.filter(function (dependant) {
return !dependant.root && names.indexOf(dependant.name) === -1;
});
// If the package has no dependants or the force config is enabled,
// mark it to be removed
if (!dependants.length || that._config.force) {
packages[name] = decEndpoint.canonicalDir;
return;
}
// Otherwise we need to figure it out if the user really wants to remove it,
// even with dependants
function(value, key) {
var resolved;
var fetching;
var compatible;
var childDecEndpoint = endpointParser.json2decomposed(key, value);
// Check if this depdendency should be skipped.
if (
mout.array.contains(
this._config.ignoredDependencies,
childDecEndpoint.name
)
) {
this._logger.action(
'skipped',
childDecEndpoint.name,
this.toData(decEndpoint)
);
return;
}
// Check if a compatible one is already resolved
// If there's one, we don't need to resolve it twice
resolved = this._resolved[key];
if (resolved) {
mout.object.forOwn(pkgMeta[jsonKey], function (value, key) {
var resolved;
var fetching;
var compatible;
var childDecEndpoint = endpointParser.json2decomposed(key, value);
// Check if a compatible one is already resolved
// If there's one, we don't need to resolve it twice
resolved = this._resolved[key];
if (resolved) {
// Find if there's one with the exact same target
compatible = mout.array.find(resolved, function (resolved) {
return childDecEndpoint.target === resolved.target;
}, this);
// If we found one, merge stuff instead of adding as resolved
if (compatible) {
decEndpoint.dependencies[key] = compatible;
compatible.dependants.push(decEndpoint);
compatible.dependants = this._uniquify(compatible.dependants);
return;
}
// Find one that is compatible
compatible = mout.array.find(resolved, function (resolved) {
return this._areCompatible(childDecEndpoint, resolved);
}, this);
Worker.prototype._onResolve = function (entry, ok, result) {
// Resolve/reject the deferred based on success/error of the promise
if (ok) {
entry.deferred.resolve(result);
} else {
entry.deferred.reject(result);
}
// Remove it from the executing list
mout.array.remove(this._executing, entry);
// Free up slots for every type
entry.types.forEach(this._freeSlot, this);
// Find candidates for the free slots of each type
entry.types.forEach(this._processQueue, this);
};
// to figure out the suitable one
if (semvers.length && nonSemvers.length) {
picks.push.apply(picks, semvers);
picks.push.apply(picks, nonSemvers);
// If there are only non-semver ones, the suitable is elected
// only if there's one
} else if (nonSemvers.length) {
if (nonSemvers.length === 1) {
return Q.resolve(nonSemvers[0]);
}
picks.push.apply(picks, nonSemvers);
// If there are only semver ones, figure out which one is
// compatible with every requirement
} else {
suitable = mout.array.find(semvers, function(subject) {
return semvers.every(function(decEndpoint) {
return (
subject === decEndpoint ||
semver.satisfies(
subject.pkgMeta.version,
decEndpoint.target
)
);
});
});
if (suitable) {
return Q.resolve(suitable);
}
picks.push.apply(picks, semvers);
.then(function (confirmed) {
// If the user decided to skip it, remove from the array so that it won't
// influence subsequent dependants
if (!confirmed) {
mout.array.remove(names, name);
} else {
packages[name] = decEndpoint.canonicalDir;
}
});
});
dependencies = dependencies.filter(function (dependency) {
return !mout.array.find(onlyOnce, function (stacked) {
if (dependency.endpoint) {
return mout.object.equals(dependency.endpoint, stacked.endpoint);
}
return dependency.name === stacked.name &&
dependency.source === stacked.source &&
dependency.target === stacked.target;
});
});
dependencies = dependencies.filter(function (dependency) {
return !mout.array.find(onlyOnce, function (stacked) {
if (dependency.endpoint) {
return mout.object.equals(dependency.endpoint, stacked.endpoint);
}
return dependency.name === stacked.name &&
dependency.source === stacked.source &&
dependency.target === stacked.target;
});
});