Skip to content

Commit

Permalink
Removed load caching and made loaded data available
Browse files Browse the repository at this point in the history
  • Loading branch information
mallocator committed Mar 31, 2016
1 parent f1441c2 commit 0f73cf2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
14 changes: 4 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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];
Expand Down Expand Up @@ -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);
Expand All @@ -212,8 +208,6 @@ module.exports = function (options) {
return;
}

this.options = options;

try {
var files = replace(file, options);
for (var i in files) {
Expand All @@ -225,4 +219,4 @@ module.exports = function (options) {

cb();
});
};
};
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
6 changes: 4 additions & 2 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit 0f73cf2

Please sign in to comment.