streamich / unionfs

Use multiple fs modules at once
https://www.npmjs.com/package/unionfs
The Unlicense
206 stars 24 forks source link

Document on the order of operations on underlay file systems #556

Open aleung opened 3 years ago

aleung commented 3 years ago

I thought the unionfs is trying to operate on underlay file systems in the same order as the use, but after tested it I found it's in reversed order.

It's better to be mentioned in the document.

const {Volume} = require('memfs');
const {ufs} = require('unionfs');

const vol1 = Volume.fromJSON({'/test': '1'});
const vol2 = Volume.fromJSON({'/test': '2'});

ufs
    .use(vol1)
    .use(vol2);

console.log(ufs.readFileSync('/test', 'utf8'));  // 2, NOT 1
rrthomas commented 3 years ago

Thanks for filing this, @aleung, I had exactly the same question!