Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.rename() not being "redirected" correctly #332

Open
jahilldev opened this issue Jul 27, 2021 · 2 comments
Open

fs.rename() not being "redirected" correctly #332

jahilldev opened this issue Jul 27, 2021 · 2 comments

Comments

@jahilldev
Copy link

jahilldev commented Jul 27, 2021

Hi there,

First of all, many thanks for such a great package!

I've encountered an issue with the rename() function that's returned via the link function. All of the other file system methods are working correctly, however, this one does not seem to maintain the path redirect.

For example:

const { link } = require('linkfs');
const fs = require('fs');

const linkedFs = link(fs, [[`${__dirname}/test`, `${__dirname}/dist`]]);

linkedFs.ReadStream = fs.ReadStream;
linkedFs.WriteStream = fs.WriteStream;

/* ---------------------------
 *
 * Correctly loads `./dist/package.json`
 * 
 * ------------------------ */

console.log(linkedFs.readFileSync('./test/package.json', 'utf8'));

/* ---------------------------
 *
 * Incorrectly renames file to `./test/package-test.json` instead of `./dist/package-test.json`
 * 
 * ------------------------ */

linkedFs.rename('./test/package.json', './dist/package-test.json', () => console.log('COPIED'));

Do you have any idea why this might be?

Many thanks for any help in advance, very much appreciated!

All the best

@jahilldev
Copy link
Author

jahilldev commented Jul 27, 2021

@streamich I've opened a PR here that fixes this. I've added a test case as well: #333

@ricsam
Copy link

ricsam commented Nov 30, 2024

I've forked the repo and added support for this:
https://www.npmjs.com/package/@ricsam/linkfs
https://github.com/ricsam/linkfs
npm install @ricsam/linkfs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants