2 Copyright (c) 2012, Yahoo! Inc. All rights reserved.
3 Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
6 var util = require('util'),
8 Store = require('./index');
11 * a `Store` implementation that doesn't actually store anything. It assumes that keys
12 * are absolute file paths, and contents are contents of those files.
13 * Thus, `set` for this store is no-op, `get` returns the
14 * contents of the filename that the key represents, `hasKey` returns true if the key
15 * supplied is a valid file path and `keys` always returns an empty array.
20 * var store = require('istanbul').Store.create('fslookup');
28 function LookupStore(opts) {
29 Store.call(this, opts);
32 LookupStore.TYPE = 'fslookup';
33 util.inherits(LookupStore, Store);
35 Store.mix(LookupStore, {
40 return fs.readFileSync(key, 'utf8');
42 hasKey: function (key) {
45 stats = fs.statSync(key);
46 return stats.isFile();
51 set: function (key /*, contents */) {
52 if (!this.hasKey(key)) {
53 throw new Error('Attempt to set contents for non-existent file [' + key + '] on a fslookup store');
60 module.exports = LookupStore;