Delete version from package meta if resolution is not a semver version.

This commit is contained in:
André Cruz
2013-04-28 10:56:11 +01:00
parent e52756bf9f
commit bf61ed6310
4 changed files with 261 additions and 58 deletions

View File

@@ -166,17 +166,24 @@ GitResolver.prototype._cleanup = function () {
GitResolver.prototype._savePkgMeta = function (meta) {
var deferred = Q.defer();
if (typeof meta.version === 'string' && meta.version !== this._resolution.version) {
process.nextTick(function (metaVersion) {
deferred.notify({
type: 'warn',
data: 'Version declared in the json (' + metaVersion + ') is different than the resolved one (' + this._resolution.version + ')'
});
}.bind(this, meta.version));
}
if (this._resolution.version) {
// Warn if the package meta version is different than the resolved one
if (typeof meta.version === 'string' && meta.version !== this._resolution.version) {
process.nextTick(function (metaVersion) {
deferred.notify({
type: 'warn',
data: 'Version declared in the json (' + metaVersion + ') is different than the resolved one (' + this._resolution.version + ')'
});
}.bind(this, meta.version));
}
// Ensure that the version is fulfilled with the resolution version
meta.version = this._resolution.version;
// Ensure package meta version is the same as the resolution
meta.version = this._resolution.version;
} else {
// If resolved to a target that is not a version,
// remove the version from the meta
delete meta.version;
}
// Save resolution to be used in hasNew later
meta._resolution = this._resolution;