UNPKG

bit-bin

Version:

<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b

68 lines (51 loc) 1.21 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; function _path() { const data = _interopRequireDefault(require("path")); _path = function () { return data; }; return data; } function _anyFs() { const data = require("@teambit/any-fs"); _anyFs = function () { return data; }; return data; } function _utils() { const data = require("../../utils"); _utils = function () { return data; }; return data; } /** * The virtual component filesystem */ class ComponentFS extends _anyFs().MemoryFS { /** * hash to represent all contents within this filesystem volume. */ get hash() { return ''; } toObject() {} toJSON() {} static fromVinyls(files) { const fs = new ComponentFS(); files.forEach(file => { let dirPath = file.relativeDir; if (!dirPath.startsWith('/')) dirPath = _path().default.join('/', dirPath); fs.mkdirpSync(dirPath); fs.writeFileSync(`/${file.relative}`, _utils().eol.auto(file.contents || '')); }); return fs; } } exports.default = ComponentFS;