From 0f73cf223de4335e67a724288d1a2c000599c6ec Mon Sep 17 00:00:00 2001 From: Ravi Gairola Date: Wed, 30 Mar 2016 19:38:26 -0700 Subject: [PATCH] Removed load caching and made loaded data available --- index.js | 14 ++++---------- readme.md | 2 +- test/index.test.js | 6 ++++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index c3e5b1a..c9cd592 100644 --- a/index.js +++ b/index.js @@ -15,9 +15,6 @@ var through = require('through2'); */ var dictionaries = {}; - -var locations = []; - /** * Defauls options that are used if they are not overwritten by the user. * @type {Object} @@ -37,10 +34,6 @@ var defaults = { * @param options */ function load(options) { - if (locations[options.locales]) { - return; - } - locations[options.locales] = true; var files = fs.readdirSync(options.locales); for (var i in files) { var file = files[i]; @@ -201,6 +194,9 @@ module.exports = function (options) { options = _.assign({}, defaults, options); load(options); + module.exports.options = options; + module.exports.dictionaries = dictionaries; + return through.obj(function (file, enc, cb) { if (file.isNull()) { cb(null, file); @@ -212,8 +208,6 @@ module.exports = function (options) { return; } - this.options = options; - try { var files = replace(file, options); for (var i in files) { @@ -225,4 +219,4 @@ module.exports = function (options) { cb(); }); -}; +}; \ No newline at end of file diff --git a/readme.md b/readme.md index ed9d77f..2c15b5f 100644 --- a/readme.md +++ b/readme.md @@ -107,4 +107,4 @@ generated. The option is ignored if it is missing. Type: Array(string) Default: ```undefined``` -The opposite of the whitelist. Any language specified here will be ignored during processing. +The opposite of the whitelist. Any language specified here will be ignored during processing. diff --git a/test/index.test.js b/test/index.test.js index 3562fce..ef8a4e8 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -34,7 +34,7 @@ function helper() { files.push(file); }); stream.on('finish', () => { - validatorCb(files, stream.options); + validatorCb(files, plugin.options); }); stream.write(new File({ path: 'test/helloworld.html', @@ -179,7 +179,9 @@ describe('gulp-international', () => { it('should throw an error if a file is a stream', () => { - var stream = plugin(); + var stream = plugin({ + locales: 'test/locales' + }); try { stream.write(new File({ path: 'test/helloworld.html',