How to use mem-fs-editor - 9 common examples

To help you get started, we’ve selected a few mem-fs-editor 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 alibaba / beidou / packages / beidou-cli / lib / commands / init.js View on Github external
async 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) => {
          log.info('write to:%s', to);
          return this.replaceTemplate(content, locals);
        },
      });
    }

    // write boilerplate base info to dist pkg info
github LengYXin / wtmfront-cli / bin / index-init.js View on Github external
#!/usr/bin/env node
const program = require('commander');
const memFs = require('mem-fs');
const editor = require('mem-fs-editor');
const fsExtra = require('fs-extra');
const ora = require('ora');
const store = memFs.create();
const fsEditor = editor.create(store);
const rootPath = process.cwd();
const path = require('path');
const chalk = require('chalk');
const child_process = require('child_process')
const log = require('../lib/log');
const download = require('../lib/download');
const server = require('../server/index');

// download('test');

program.usage('  ').parse(process.argv)

// 根据输入,获取项目名称
const projectName = program.args[0]
let projectType = program.args[1]
let projectUrl = program.args[2]
github yeoman / generator / lib / index.js View on Github external
);
    assert(
      this.options.resolved,
      'You must provide the resolved path value. Use env#create() to create a new generator.'
    );
    this.env = this.options.env;
    this.resolved = this.options.resolved;

    // Ensure the environment support features this yeoman-generator version require.
    require('yeoman-environment').enforceUpdate(this.env);

    this.description = this.description || '';

    this.async = () => () => {};

    this.fs = FileEditor.create(this.env.sharedFs);

    this.conflicter = new Conflicter(this.env.adapter, this.options.force, {
      bail: this.options.bail,
      ignoreWhitespace: this.options.whitespace,
      skipRegenerate: this.options.skipRegenerate,
      dryRun: this.options.dryRun
    });

    // Mirror the adapter log method on the generator.
    //
    // example:
    // this.log('foo');
    // this.log.error('bar');
    this.log = this.env.adapter.log;

    // Determine the app root
github sharvit / mongoose-data-seed / src / bin / generate / index.js View on Github external
userSeedersFolderPath,
  } = config;

  const seederName = _.upperFirst(_.camelCase(name));
  const seederFileName = `${_.kebabCase(name)}.seeder.js`;
  const seederFilePath = path.join(userSeedersFolderPath, seederFileName);
  const seederFileRelativePath = path.join(
    userSeedersFolderName,
    seederFileName
  );
  const templatePath = useEs6Generator
    ? path.join(__dirname, '../../../templates/seeder.es6.js')
    : path.join(__dirname, '../../../templates/seeder.js');

  const store = memFs.create();
  const fs = editor.create(store);

  if (fs.exists(seederFilePath)) {
    console.log(
      `${chalk.red('ERROR')} ${seederFileRelativePath} are already exists`
    );
    throw new Error('exit');
  }

  fs.copyTpl(templatePath, seederFilePath, { seederName });

  fs.commit(() => {
    console.log(`${chalk.green('CREATED')} ${seederFileRelativePath}`);
  });
}
github NervJS / taro / packages / taro-cli / src / create / creator.ts View on Github external
constructor (sourceRoot?: string) {
    const store = memFs.create()
    this.fs = editor.create(store)
    this.sourceRoot(sourceRoot || path.join(getRootPath()))
    this.init()
  }
github sharvit / mongoose-data-seed / src / lib / core / seeder-generator.js View on Github external
_initMemFs() {
    const store = memFs.create();
    this.fs = editor.create(store);
  }
github sharvit / mongoose-data-seed / src / lib / core / installer.js View on Github external
_initMemFs() {
    const store = memFs.create();
    this._memFsEditor = editor.create(store);
  }

mem-fs-editor

File edition helpers working on top of mem-fs

MIT
Latest version published 6 months ago

Package Health Score

82 / 100
Full package analysis

Popular mem-fs-editor functions

Similar packages