How to use the memfs.vol.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 Crypto-Punkers / resolver-engine / src / context / fs.ts View on Github external
constructor() {
    this.fs = memfs;

    // define /tmp/ dir
    vol.fromJSON({ ".stub": "" }, "/tmp/");
  }
github sapegin / mrm-core / src / __tests__ / core.spec.js View on Github external
it('should escape `', () => {
		vol.fromJSON({ '/a': 'Hello, `${foo}`!' });

		const fn = () => core.applyTemplate('/a', { foo: 'Bar' });
		expect(fn).not.toThrowError();

		const result = fn();
		expect(result).toBe('Hello, `Bar`!');
	});
github Crypto-Punkers / resolver-engine / test / __tests__ / resolvers / urlresolver.spec.ts View on Github external
it("returns null on non-urls", async function() {
    vol.fromJSON({
      "./relative/path.file": "wrong",
    });

    expect(await instance("relative/path.file", defaultContext())).toBeNull();
  });
github sapegin / mrm-core / src / formats / __tests__ / yaml.spec.js View on Github external
it('save() should update file', () => {
		vol.fromJSON(json);
		yaml(filename)
			.set('foo', 1)
			.save();
		expect(vol.toJSON()).toMatchSnapshot();
	});
github smartive / kuby / test / commands / namespace / namespace.create.spec.ts View on Github external
it('should load the default role file if one exists', async () => {
    vol.fromJSON({
      [Filepathes.namespaceDefaultRolePath]: 'foobar',
    });
    await namespaceCreateCommand.handler({ name: 'ns3' } as any);
    expect((prompt as any as jest.Mock).mock.calls[0][0].map((q: any) => q.default)[2]).toBe('foobar');
  });
github sapegin / mrm-core / src / formats / __tests__ / ini.spec.js View on Github external
it('should return list of sections', () => {
		vol.fromJSON(json);
		const file = ini(filename);
		expect(file.get()).toEqual(['foo']);
	});
github sakuli / sakuli / packages / sakuli-commons / src / testing / fs-layout / mock-fs.function.ts View on Github external
export function mockFs(_layout: FsLayout) {
    (process.env.MEMFS_DONT_WARN as any) = true;
    layout = _layout;

    vol.fromJSON(flattenLayout(_layout));
}
github smartive / kuby / test / commands / kubectl / kubectl.remove.spec.ts View on Github external
beforeEach(() => {
    vol.fromJSON({
      [posix.join(Filepathes.kubectlInstallPath, 'v1.12.1', 'kubectl')]: 'kubectl',
      [posix.join(Filepathes.kubectlInstallPath, 'v1.12.2', 'kubectl')]: 'kubectl',
      [posix.join(Filepathes.kubectlInstallPath, 'v1.10.0', 'kubectl')]: 'kubectl',
      [posix.join(Filepathes.kubectlInstallPath, 'v1.8.4', 'kubectl')]: 'kubectl',
    });
    vol.mkdirpSync('/usr/local/bin/');
    vol.symlinkSync(posix.join(Filepathes.kubectlInstallPath, 'v1.10.0', 'kubectl'), '/usr/local/bin/kubectl');
  });
github Crypto-Punkers / resolver-engine / integration-tests / src / __tests__ / gatherSources.spec.ts View on Github external
it.each(data)("%s", async function(message, testFs, input, cwd, provider) {
    const EXPECTED_FILES = expectedOutput(testFs, provider, cwd);

    vol.fromJSON(testFs);
    const fileList = await gatherSources(input, cwd, resolver);
    expect(fileList.sort((a, b) => a.url.localeCompare(b.url))).toEqual(
      EXPECTED_FILES.sort((a, b) => a.url.localeCompare(b.url)),
    );
  });
github nrwl / nx / packages / workspace / src / utils / fileutils.spec.ts View on Github external
beforeEach(() => {
    vol.fromJSON(
      {
        './README.md': 'hello',
        './.nxignore': stripIndents`
          apps/demo/tmp.txt
          tmp/
        `,
        './.gitignore': stripIndents`
          *.js
          node_modules/
        `,
        './apps/demo/src/index.ts': 'console.log("hello");',
        './apps/demo/tmp.txt': '...',
        './apps/demo/tmp.js': 'console.log("tmp")',
        './workspace.json': '{}'
      },
      '/root'