Giter Site home page Giter Site logo

linkfs's Introduction

linkfs

Redirects filesystem paths.

npm install --save linkfs
import {link} from 'linkfs';
import {fs} from 'memfs';

fs.writeFileSync('/foo', 'bar');
const lfs = link(fs, ['/foo2', '/foo']);
console.log(lfs.readFileSync('/foo2', 'utf8')); // bar

Reference

link(fs, rewrites)

Returns a new fs-like object with redirected file paths.

fs is the source fs-like object.

rewrites is a 2-tuple or an array of 2-tuples, where each 2-tuple has a form of [from, to]. from is the new, virtual path; and to is an existing path in the fs filesystem.

const lfs = link(fs, ['/foo', '/bar']);

or

const lfs = link(fs, [
    ['/foo1', '/bar1'],
    ['/foo2', '/bar2'],
    ['/foo3', '/bar3'],
]);

License

Unlicense - public domain.

linkfs's People

Contributors

renovate-bot avatar renovate[bot] avatar streamich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

linkfs's Issues

Respect require calls

require doesnt respect the linked fs. There are some Modules out there which has the ability, but all have different drawbacks. i liked your library the most!

I think the module Module must be patched to make this work right?

Not working on Windows

Unfortunately this nice module doesn't work on Windows. [edit] wrong explanations removed [/edit]

[Edit] In the end we just need to change line 131 to

 const regex = new RegExp('^(' + from.replace(/\\/g, '\\\\') + ')(\\\\|\/|$)');

Thanks a lot!

p.s. rewriting from / or (empty string) to some path doesn't work though it would be nice...

Dependency deprecation warning: babel-preset-es2015 (nvm)

On registry https://registry.npmjs.org/, the "latest" version (v6.24.1) of dependency babel-preset-es2015 has the following deprecation notice:

๐Ÿ™Œ Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!

Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.

Please take the actions necessary to rename or substitute this deprecated package and commit to your base branch. If you wish to ignore this deprecation warning and continue using babel-preset-es2015 as-is, please add it to your ignoreDeps array in Renovate config before closing this issue, otherwise another issue will be recreated the next time Renovate runs.

Affected package file(s): package.json

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • memfs 4.6.0
  • jest 29.7.0
  • ts-jest 29.1.1
  • typescript 5.3.2
  • ts-node 10.9.1
  • babel-cli 6.26.0
  • babel-preset-es2015 6.24.1
  • gulp 4.0.2
  • gulp-typescript 5.0.1
  • source-map-support 0.5.21
  • nyc 15.1.0
  • semantic-release 22.0.9
  • @types/jest 29.5.10
  • @types/node 9.6.61
nvm
.nvmrc
  • node 8.17.0
travis
.travis.yml
  • node 9
  • node 8
  • node 7
  • node 6

  • Check this box to trigger a request for Renovate to run again on this repository

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (github>whitesource/merge-confidence:beta)

Dependency deprecation warning: babel-preset-es2015 (npm)

On registry https://registry.yarnpkg.com/, the "latest" version (v6.24.1) of dependency babel-preset-es2015 has the following deprecation notice:

๐Ÿ™Œ Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!

Marking the latest version of an npm package as deprecated results in the entire package being considered deprecated, so contact the package author you think this is a mistake.

Affected package file(s): package.json

If you don't care about this, you can close this issue and not be warned about babel-preset-es2015's deprecation again. If you would like to completely disable all future deprecation warnings then add the following to your config:

"suppressNotifications": ["deprecationWarningIssues"]

fs.rename() not being "redirected" correctly

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.