mirror of
https://github.com/bower/bower.git
synced 2026-02-12 06:55:04 -05:00
Add static function to clear the internal resolvers cache, fix some issues.
This commit is contained in:
@@ -17,7 +17,7 @@ var Resolver = function (source, options) {
|
||||
|
||||
this._source = source;
|
||||
this._target = options.target || '*';
|
||||
this._name = options.name || this._source;
|
||||
this._name = options.name || path.basename(this._source);
|
||||
this._guessedName = !options.name;
|
||||
this._config = options.config || config;
|
||||
};
|
||||
@@ -79,6 +79,10 @@ Resolver.prototype.getPkgMeta = function () {
|
||||
|
||||
// -----------------
|
||||
|
||||
Resolver.clearRuntimeCache = function () {};
|
||||
|
||||
// -----------------
|
||||
|
||||
// Abstract function that should be implemented by concrete resolvers
|
||||
Resolver.prototype._resolveSelf = function () {
|
||||
throw new Error('_resolveSelf not implemented');
|
||||
@@ -186,4 +190,5 @@ Resolver.prototype._createIgnoreFilter = function (ignore) {
|
||||
return list.matches(filename);
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = Resolver;
|
||||
@@ -6,6 +6,11 @@ var cmd = require('../../util/cmd');
|
||||
|
||||
var GitRemoteResolver = function (source, options) {
|
||||
GitResolver.call(this, source, options);
|
||||
|
||||
// If the name was guessed, remove the trailing .git
|
||||
if (this._guessedName && mout.string.endsWith(this._name, '.git')) {
|
||||
this._name = this._name.slice(0, -4);
|
||||
}
|
||||
};
|
||||
|
||||
util.inherits(GitRemoteResolver, GitResolver);
|
||||
|
||||
@@ -10,14 +10,10 @@ var createError = require('../../util/createError');
|
||||
|
||||
var GitResolver = function (source, options) {
|
||||
Resolver.call(this, source, options);
|
||||
|
||||
// Guess the name
|
||||
if (this._guessedName) {
|
||||
this._name = path.basename(this._source, '.git');
|
||||
}
|
||||
};
|
||||
|
||||
util.inherits(GitResolver, Resolver);
|
||||
mout.object.mixIn(GitResolver, Resolver);
|
||||
|
||||
// -----------------
|
||||
|
||||
@@ -275,4 +271,11 @@ GitResolver.fetchBranches = function (source) {
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
GitResolver.clearRuntimeCache = function () {
|
||||
GitResolver._branches = null;
|
||||
GitResolver._tags = null;
|
||||
GitResolver._versions = null;
|
||||
GitResolver._refs = null;
|
||||
};
|
||||
|
||||
module.exports = GitResolver;
|
||||
|
||||
Reference in New Issue
Block a user