How to use mem-fs - 10 common examples

To help you get started, we’ve selected a few mem-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 xiaomuzhu / create-component / src / cli / Init / init-command.ts View on Github external
private async copyScaffold() {
    const { proName, proPath, projectLanguage, frameworkType, usePrecommit, cssinjs } = this.options

    const extraOptions = {
      year: utils.getYear(),
    }

    const allOptions = _.merge(this.options, extraOptions)
    const scaffoldType = {
      FrameworkType: frameworkType,
      Language: projectLanguage,
    }

    // 内存管理
    const store = memFs.create()
    const fsEditor = editor.create(store)

    const globOptions = {
      globOptions: {
        dot: true,
      },
    }
    // 拷贝脚手架
    fsEditor.copyTpl(utils.getScaffoldPath(scaffoldType), proPath, allOptions, {}, globOptions)

    fsEditor.copyTpl(utils.getCommonPath('LICENSE', this.options.license), proPath, allOptions)

    fsEditor.copyTpl(utils.getCommonPath('readme'), proPath, allOptions)

    fsEditor.copyTpl(utils.getCommonPath('setup'), proPath, allOptions)
github alibaba / beidou / packages / beidou-init / lib / command / init-command.js View on Github external
* processFiles(targetDir, templateDir) {
    // const src = path.join(templateDir, 'boilerplate');
    const src = path.join(templateDir);
    const locals = {};
    const fsEditor = editor.create(memFs.create());
    const files = glob.sync('**/*', { cwd: src, dot: true, nodir: true });
    for (const file of files) {
      const from = path.join(src, file);
      const to = path.join(
        targetDir,
        this.replaceTemplate(this.fileMapping[file] || file, locals)
      );
      fsEditor.copy(from, to, {
        process: (content) => {
          this.log('write to:%s', to);
          return this.replaceTemplate(content, locals);
        },
      });
    }

    // write boilerplate base info to dist pkg info
github SBoudrias / mem-fs-editor / __tests__ / write-json.js View on Github external
beforeEach(() => {
    store = memFs.create();
    fs = editor.create(store);
  });
github SBoudrias / mem-fs-editor / __tests__ / read-json.js View on Github external
beforeEach(() => {
    store = memFs.create();
    fs = editor.create(store);
  });
github SBoudrias / mem-fs-editor / __tests__ / extend-json.js View on Github external
beforeEach(() => {
    store = memFs.create();
    fs = editor.create(store);
  });
github sharvit / mongoose-data-seed / src / bin / init / index.js View on Github external
function init({ es6 = false, seedersFolder = 'seeders' }) {
  const store = memFs.create();
  const fs = editor.create(store);

  _writeUserGeneratorConfig();
  _writeUserConfig();
  _createSeedersFolder();

  function _writeUserGeneratorConfig() {
    const {
      projectRoot,
      userGeneratorConfigExists,
      userGeneratorConfigFilename,
      userGeneratorConfigFilepath,
    } = config;

    const generatorConfig = { es6, seedersFolder };
github trainyard / choo-cli / lib / utils.js View on Github external
const debug = require('debug')('choo-cli:utils')
const store = require('mem-fs').create()
const xfs = require('mem-fs-editor').create(store)
const { kebabCase, camelCase } = require('lodash')
const { parse } = require('espree')
const exec = require('./exec')
const path = require('path')
const once = require('ramda').once
const walkBack = require('walk-back')
const chalk = require('chalk')
const delim = (require('os').platform() === 'win32') ? '\\' : '/'
const message = msg => console.log(msg)
const cwd = process.cwd()
const resolvePath = path.resolve

const newProjectPath = (projectName) => (dir) => resolvePath(cwd, projectName, dir || '')
const findConfig = once(() => walkBack(process.cwd(), 'choo.yaml'))
const findRootPath = once(() => {
github jhwohlgemuth / tomo-cli / src / utils.js View on Github external
constructor(options = {sourceDirectory: join(__dirname, 'templates')}) {
        const {sourceDirectory} = options;
        const targetDirectory = './';
        const fs = editor.create(memFs.create());
        const queue = new Queue({concurrency: 1});
        assign(this, {fs, queue, sourceDirectory, targetDirectory});
    }
    /**
github xiaomuzhu / create-component / dist / cli / Init / init-command.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
            const { proName, proPath, projectLanguage, frameworkType, usePrecommit, cssinjs } = this.options;
            const extraOptions = {
                year: index_1.default.getYear(),
            };
            const allOptions = _.merge(this.options, extraOptions);
            const scaffoldType = {
                FrameworkType: frameworkType,
                Language: projectLanguage,
            };
            const store = memFs.create();
            const fsEditor = editor.create(store);
            const globOptions = {
                globOptions: {
                    dot: true,
                },
            };
            fsEditor.copyTpl(index_1.default.getScaffoldPath(scaffoldType), proPath, allOptions, {}, globOptions);
            fsEditor.copyTpl(index_1.default.getCommonPath('LICENSE', this.options.license), proPath, allOptions);
            fsEditor.copyTpl(index_1.default.getCommonPath('readme'), proPath, allOptions);
            fsEditor.copyTpl(index_1.default.getCommonPath('setup'), proPath, allOptions);
            if (!cssinjs) {
                fsEditor.copyTpl(index_1.default.getCommonPath('css'), `${proPath}/src/`, allOptions);
            }
            if (this.options.useCommitlint) {
                fsEditor.copyTpl(index_1.default.getCommonPath('commitlint'), proPath, {}, {}, globOptions);
            }

mem-fs

Simple in-memory vinyl file store

MIT
Latest version published 4 months ago

Package Health Score

75 / 100
Full package analysis

Popular mem-fs functions