How to use the memfs/lib/volume.Volume 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 wasmerio / wasmer-js / packages / wasmfs / src / index.ts View on Github external
fromJSON(fsJson: any) {
    this.volume = new Volume();
    this.fromJSONFixed(this.volume, fsJson);
    // @ts-ignore
    this.fs = createFsFromVolume(this.volume);
    this.volume.releasedFds = [0, 1, 2];
    const fdErr = this.volume.openSync("/dev/stderr", "w");
    const fdOut = this.volume.openSync("/dev/stdout", "w");
    const fdIn = this.volume.openSync("/dev/stdin", "r");
    assert(fdErr === 2, `invalid handle for stderr: ${fdErr}`);
    assert(fdOut === 1, `invalid handle for stdout: ${fdOut}`);
    assert(fdIn === 0, `invalid handle for stdin: ${fdIn}`);
  }
github teambit / bit / components / core / capsule / capsule.ts View on Github external
static async create(
    containerFactory: (options: ContainerFactoryOptions) => Promise,
    volume: Volume = new Volume(),
    initialState: State = new State(),
    console: Console = new Console()
  ): Promise {
    const container = await containerFactory({ image: this.image, config: this.config });
    const fs = await ContainerFS.fromJSON(container, {});
    return new this(container, this.buildFs(volume, fs), console, initialState) as T;
  }
}
github wasmerio / wasmer-js / packages / wasmfs / src / index.ts View on Github external
constructor() {
    this.volume = new Volume();
    this.fs = createFsFromVolume(this.volume);
    this.fromJSON({
      "/dev/stdin": "",
      "/dev/stdout": "",
      "/dev/stderr": ""
    });
  }
github wasmerio / wasmer-js / packages / wasmfs / lib / index.ts View on Github external
constructor() {
    this.volume = new Volume();
    this.fs = createFsFromVolume(this.volume);
    this.fromJSON({
      "/dev/stdin": "",
      "/dev/stdout": "",
      "/dev/stderr": ""
    });
  }
github teambit / bit / components / core / capsule / dist / capsule.js View on Github external
Capsule.create = function (containerFactory, volume, initialState, console) {
        if (volume === void 0) { volume = new volume_1.Volume(); }
        if (initialState === void 0) { initialState = new state_1.default(); }
        if (console === void 0) { console = new console_1.default(); }
        return __awaiter(this, void 0, Promise, function () {
            var container, fs;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, containerFactory({ image: this.image, config: this.config })];
                    case 1:
                        container = _a.sent();
                        return [4 /*yield*/, container_1.ContainerFS.fromJSON(container, {})];
                    case 2:
                        fs = _a.sent();
                        return [2 /*return*/, new this(container, this.buildFs(volume, fs), console, initialState)];
                }
            });
        });