How to use the memfs.Volume.fromJSON function in memfs

To help you get started, we’ve selected a few memfs 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 coderaiser / cloudcmd / test / rest / mv.js View on Github external
test('cloudcmd: rest: mv', async (t) => {
    const volume = {
        '/fixture/mv.txt': 'hello',
        '/fixture/tmp/a.txt': 'a',
    };
    
    const vol = Volume.fromJSON(volume, '/');
    
    const unionFS = ufs
        .use(vol)
        .use(fs);
    
    assign(unionFS, {
        promises: fs.promises,
    });
    mockRequire('fs', unionFS);
    
    reRequire('@cloudcmd/rename-files');
    reRequire('@cloudcmd/move-files');
    reRequire(restPath);
    
    const cloudcmd = reRequire(cloudcmdPath);
    const {createConfigManager} = cloudcmd;
github sveltech / routify / test / unit / build.pta.js View on Github external
t.test(name, async t => {
        const { default: spec } = await import(resolveSample(file))

        const vol = Volume.fromJSON(spec.files)

        const build = Builder(
          {
            ...spec.options,
            fsa: fsa.from(vol),
          },
          true
        )

        const actual = await build(true)

        const expectedFilename = resolveSample(`${name}.expected.js`)
        const hasExpected = await fsa.exists(expectedFilename)

        if (!hasExpected) {
          await fsa.writeFile(expectedFilename, actual, 'utf8')
github jan-molak / serenity-js / packages / core / spec / FakeFS.ts View on Github external
if (! entries.length) {
                return ({
                    [ currentPath ]: void 0,
                });
            }

            return Object.keys(currentStructure).reduce((acc, key) =>  {
                return ({
                    ...acc,
                    ...flatten(currentStructure[key], path.join(currentPath, key)),
                });
            }, {});
        }

        return createFsFromVolume(Volume.fromJSON(flatten(tree), cwd)) as typeof fs;
    }
}
github s-panferov / tygen / packages / tygen-reflector / src / helpers.ts View on Github external
export function createMemoryFileSystem(): FileSystem {
	return Volume.fromJSON({}) as any
}
github apollographql / apollo-tooling / packages / apollo / src / __mocks__ / localfs.ts View on Github external
import { Volume, createFsFromVolume } from "memfs";
import { patchFs } from "fs-monkey";

export const vol = Volume.fromJSON({});
export const fs = createFsFromVolume(vol);

export function withGlobalFS(thunk: () => T): T {
  const unpatch = patchFs(vol);
  const ret = thunk();
  unpatch();
  return ret;
}