dominictarr / rc

The non-configurable configuration loader for lazy people.
Other
1.02k stars 97 forks source link

Allow to read file with same name after changing current working directory #101

Open pvdlg opened 6 years ago

pvdlg commented 6 years ago

Currently it seems rc caches the file content by name rather than using the full path of the file. That create a situation in which a given filename won't be loaded if the same filename was loaded from another directory before.

Here is the steps to reproduce:

// File `/directory_1/myapprc`
property = 1
// File `/directory_2/myapprc`
property = 2
process.chdir('/directory_1');
var conf1 = require('rc')('myapprc');
console.log(conf1.property);
// 1

process.chdir('/directory_2');
var conf2 = require('rc')('myapprc');
console.log(conf2.property);
// 1 => should be 2