mirror of
https://github.com/bower/bower.git
synced 2026-04-24 03:00:19 -04:00
Add ability to clear runtime cache for long-lived programs to call.
This commit is contained in:
@@ -134,6 +134,12 @@ PackageRepository.prototype.list = function () {
|
||||
return this._resolveCache.list();
|
||||
};
|
||||
|
||||
PackageRepository.clearRuntimeCache = function () {
|
||||
ResolveCache.clearRuntimeCache();
|
||||
RegistryClient.clearRuntimeCache();
|
||||
resolverFactory.clearRuntimeCache();
|
||||
};
|
||||
|
||||
// ---------------------
|
||||
|
||||
PackageRepository.prototype._resolve = function (resolver, logger) {
|
||||
|
||||
@@ -102,7 +102,7 @@ function getConstructor(source, config, registryClient) {
|
||||
});
|
||||
}
|
||||
|
||||
function createResolver(decEndpoint, config, logger, registryClient) {
|
||||
function createInstance(decEndpoint, config, logger, registryClient) {
|
||||
return getConstructor(decEndpoint.source, config, registryClient)
|
||||
.spread(function (ConcreteResolver, source, fromRegistry) {
|
||||
var resolverDecEndpoint = mout.object.pick(decEndpoint, ['name', 'target']);
|
||||
@@ -118,6 +118,12 @@ function createResolver(decEndpoint, config, logger, registryClient) {
|
||||
});
|
||||
}
|
||||
|
||||
createResolver.getConstructor = getConstructor;
|
||||
function clearRuntimeCache() {
|
||||
mout.object.values(resolvers).forEach(function (ConcreteResolver) {
|
||||
ConcreteResolver.clearRuntimeCache();
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = createResolver;
|
||||
module.exports = createInstance;
|
||||
module.exports.getConstructor = getConstructor;
|
||||
module.exports.clearRuntimeCache = clearRuntimeCache;
|
||||
|
||||
17
lib/index.js
17
lib/index.js
@@ -1,8 +1,11 @@
|
||||
var abbrev = require('abbrev');
|
||||
var mout = require('mout');
|
||||
var commands = require('./commands');
|
||||
var PackageRepository = require('./core/PackageRepository');
|
||||
|
||||
var abbreviations;
|
||||
var abbreviations = abbrev(names(commands));
|
||||
abbreviations.i = 'install';
|
||||
abbreviations.rm = 'uninstall';
|
||||
|
||||
function names(obj, prefix, stack) {
|
||||
prefix = prefix || '';
|
||||
@@ -21,12 +24,16 @@ function names(obj, prefix, stack) {
|
||||
return stack;
|
||||
}
|
||||
|
||||
abbreviations = abbrev(names(commands));
|
||||
abbreviations.i = 'install';
|
||||
abbreviations.rm = 'uninstall';
|
||||
function clearRuntimeCache() {
|
||||
// Note that the runtime cache is only cleared statically
|
||||
// If you got an instance of an architecture component that holds cache,
|
||||
// you should get rid of it and instantiate a new one after calling this
|
||||
PackageRepository.clearRuntimeCache();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
commands: commands,
|
||||
config: require('./config'),
|
||||
abbreviations: abbreviations
|
||||
abbreviations: abbreviations,
|
||||
reset: clearRuntimeCache
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user