Move completion cache results to ~/.bower/cache/__bowercompletion__

for cache-clean command to be able to clean it.

__bowercompletion__ to avoid potential naming conflicts.
This commit is contained in:
Mickael Daniel
2012-12-25 13:50:57 +01:00
parent 8a00820dbb
commit 8dbffe6fa7
2 changed files with 31 additions and 1 deletions

View File

@@ -26,7 +26,7 @@ var folder = process.platform === 'win32'
var config = require('rc') ('bower', {
cache : path.join(roaming, folder, 'cache'),
links : path.join(roaming, folder, 'links'),
completion : path.join(roaming, folder, 'completion'),
completion : path.join(roaming, folder, 'cache/__bowercompletion__'),
json : 'component.json',
endpoint : 'https://bower.herokuapp.com',
directory : 'components'

View File

@@ -5,6 +5,7 @@ var path = require('path');
var assert = require('assert');
var complete = require('../lib/util/completion');
var config = require('../lib/core/config');
var command = require('../lib/commands/completion');
var commands = require('../lib/commands');
@@ -126,4 +127,33 @@ describe('completion', function () {
cmd.on('end', done);
});
describe('completion cache clean', function() {
it('caches the result of <endpoint>/packages to ~/.bower/cache/__bowercompletion__', function(done) {
complete.log = function() {};
var cmd = command(['install', 'jquery-'], {
COMP_CWORD: '2',
COMP_LINE: 'bower install jquery-',
COMP_POINT: '14'
});
cmd.on('end', function() {
var cache = path.join(config.completion, 'install.json');
fs.stat(cache, done);
});
})
it('is cleared with cache-clean command', function(done) {
commands['cache-clean']().on('end', function() {
var cache = path.join(config.completion, 'install.json');
fs.stat(cache, function(err) {
done(err ? null : new Error('completion results wasn\'t cleaned'));
});
});
});
});
});