How to use the memory-fs.prototype function in memory-fs

To help you get started, we’ve selected a few memory-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Mayank1791989 / gql / src / __mocks__ / fs.js View on Github external
function createNewMemoryFileSystem(): MemoryFileSystem {
  const _fs = new MemoryFileSystem();
  // Note: binding all methods of _fs
  // some libs use individual fs method
  // e.g const writeFileSync = fs.writeFileSync
  //  writeFileSync() // this will call method with wrong this
  // happening in find-config package
  Object.keys(MemoryFileSystem.prototype).forEach((key) => {
    if (typeof _fs[key] === 'function') {
      _fs[key] = _fs[key].bind(_fs);
    }
  });
  return _fs;
}
github parcel-bundler / parcel / packages / core / repl / memory-fs.js View on Github external
const MemoryFileSystem = require('memory-fs');
const fs = new MemoryFileSystem();
for (let f in MemoryFileSystem.prototype) {
  if (typeof MemoryFileSystem.prototype[f] === 'function') {
    fs[f] = MemoryFileSystem.prototype[f].bind(fs);
  }
}
fs.lstat = fs.stat;
fs.lstatSync = fs.statSync;

const readFileSync = fs.readFileSync;
fs.readFileSync = (path, encoding) => {
  if (encoding && encoding.encoding) encoding = encoding.encoding;
  return readFileSync(path, encoding);
};

const createWriteStream = fs.createWriteStream;
fs.createWriteStream = path => {
  const s = createWriteStream(path);
  return {
github parcel-bundler / parcel / packages / core / repl / memory-fs.js View on Github external
const MemoryFileSystem = require('memory-fs');
const fs = new MemoryFileSystem();
for (let f in MemoryFileSystem.prototype) {
  if (typeof MemoryFileSystem.prototype[f] === 'function') {
    fs[f] = MemoryFileSystem.prototype[f].bind(fs);
  }
}
fs.lstat = fs.stat;
fs.lstatSync = fs.statSync;

const readFileSync = fs.readFileSync;
fs.readFileSync = (path, encoding) => {
  if (encoding && encoding.encoding) encoding = encoding.encoding;
  return readFileSync(path, encoding);
};

const createWriteStream = fs.createWriteStream;
fs.createWriteStream = path => {
  const s = createWriteStream(path);

memory-fs

A simple in-memory filesystem. Holds data in a javascript object.

MIT
Latest version published 5 years ago

Package Health Score

70 / 100
Full package analysis

Popular memory-fs functions