GithubHelp home page GithubHelp logo

isabella232 / mem-fs-editor Goto Github PK

View Code? Open in Web Editor NEW

This project forked from experience-monks/mem-fs-editor

0.0 0.0 0.0 124 KB

File edition helpers working on top of mem-fs (https://github.com/SBoudrias/mem-fs)

License: MIT License

JavaScript 100.00%

mem-fs-editor's Introduction

mem-fs-editor Build Status

File edition helpers working on top of mem-fs

Usage

var memFs = require('mem-fs');
var editor = require('mem-fs-editor');

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

fs.write('somefile.js', 'var a = 1;');

#read(filepath, [options])

Read a file and return its contents as a string.

You can alternatively get the raw contents buffer if you pass options.raw = true.

#readJSON(filepath)

Read a file and parse its contents as JSON.

#write(filepath, contents)

Replace the content of a file (existing or new) with a string or a buffer.

#delete(filepath)

Delete a file or a directory.

#copy(from, to, [options])

Copy a file from the from path to the to path.

Optionally, pass an options.process function (process(contents)) returning a string or a buffer who'll become the new file content. The process function will take a single contents argument who is the copied file contents as a Buffer.

from can be a glob pattern that'll be match against the file system. If that's the case, then to must be an output directory.

#copyTpl(from, to, context, [settings])

Copy the from file and parse its content as an underscore template where context is the template context.

Optionnally pass a template settings object.

#commit([filters,] callback)

Persist every changes made to files in the mem-fs store to disk.

If provided, filters is an array of TransformStream to be applied on a stream of vinyl files (like gulp plugins).

callback is called once the files are updated on disk.

mem-fs-editor's People

Contributors

sboudrias avatar mikkoh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.