Coder Social home page Coder Social logo

vinyl-fs's Introduction

vinyl-fs NPM version Build Status Coveralls Status Dependency Status

Information

Packagevinyl-fs
DescriptionVinyl adapter for the file system
Node Version>= 0.10

Usage

var map = require('map-stream');
var fs = require('vinyl-fs');

var log = function(file, cb) {
  console.log(file.path);
  cb(null, file);
};

fs.src(['./js/**/*.js', '!./js/vendor/*.js'])
  .pipe(map(log))
  .pipe(fs.dest('./output'));

API

src(globs[, opt])

  • Takes a glob string or an array of glob strings as the first argument.
  • Globs are executed in order, so negations should follow positive globs. For example:
fs.src(['!b*.js', '*.js'])

would not exclude any files, but this would

fs.src(['*.js', '!b*.js'])
  • Possible options for the second argument:

    • cwd - Specify the working directory the folder is relative to.

      • Default is process.cwd().
    • base - Specify the folder relative to the cwd. This is used to determine the file names when saving in .dest().

      • Default is where the glob begins if any.
      • Default is process.cwd() if there is no glob.
    • buffer - true or false if you want to buffer the file.

      • Default value is true.
      • false will make file.contents a paused Stream.
    • read - true or false if you want the file to be read or not. Useful for stuff like rming files.

      • Default value is true.
      • false will disable writing the file to disk via .dest().
    • since - Date or number if you only want files that have been modified since the time specified.

    • stripBOM - true or false if you want the BOM to be stripped on UTF-8 encoded files.

      • Default value is true.
    • passthrough - true or false if you want a duplex stream which passes items through and emits globbed files.

      • Default is false.
    • sourcemaps - true or false if you want files to have sourcemaps enabled.

      • Default is false.
      • Will load inline sourcemaps and resolve sourcemap links from files
      • Uses gulp-sourcemaps under the hood
    • followSymlinks - true if you want to recursively resolve symlinks to their targets; set to false to preserve them as symlinks.

      • Default is true.
      • false will make file.symlink equal the original symlink's target path.
    • Any glob-related options are documented in glob-stream and node-glob.

  • Returns a Readable stream by default, or a Duplex stream if the passthrough option is set to true.

  • This stream emits matching vinyl File objects.

Note: UTF-8 BOM will be stripped from all UTF-8 files read with .src.

dest(folder[, opt])

  • Takes a folder path as the first argument.

  • First argument can also be a function that takes in a file and returns a folder path.

  • Possible options for the second argument:

    • cwd - Specify the working directory the folder is relative to.

      • Default is process.cwd().
    • base - Specify the folder relative to the cwd. This is used to determine the file names when saving in .dest().

      • Default is the cwd resolves to the folder path.
      • Can also be a function that takes in a file and returns a folder path.
    • mode - Specify the mode the files should be created with.

      • Default is the mode of the input file (file.stat.mode) if any.
      • Default is the process mode if the input file has no mode property.
    • dirMode - Specify the mode the directory should be created with.

      • Default is the process mode.
    • overwrite - Specify if existing files with the same path should be overwritten or not.

      • Default is true, to always overwrite existing files.
      • Can also be a function that takes in a file and returns true or false.
    • sourcemaps -

      • Default is null aka do not write sourcemaps.
      • Uses gulp-sourcemaps under the hood
      • Examples:
        • Write as inline comments
        • fs.dest('./', {sourcemaps: true})
        • Write as files in the same folder
        • fs.dest('./', {
          sourcemaps: {
          path: '.'
          }
          })
        • Any other options are passed through to gulp-sourcemaps
        • fs.dest('./', {
          sourcemaps: {
          path: '.',
          addComment: false,
          includeContent: false
          }
          })
  • Returns a Readable/Writable stream.

  • On write the stream will save the vinyl File to disk at the folder/cwd specified.

  • After writing the file to disk, it will be emitted from the stream so you can keep piping these around.

  • If the file has a symlink attribute specifying a target path, then a symlink will be created.

  • The file will be modified after being written to this stream:

    • cwd, base, and path will be overwritten to match the folder.
    • stat.mode will be overwritten if you used a mode parameter.
    • contents will have it's position reset to the beginning if it is a stream.

symlink(folder[, opt])

  • Takes a folder path as the first argument.

  • First argument can also be a function that takes in a file and returns a folder path.

  • Possible options for the second argument:

    • cwd - Specify the working directory the folder is relative to.

      • Default is process.cwd().
    • base - Specify the folder relative to the cwd. This is used to determine the file names when saving in .dest().

      • Default is the cwd resolves to the folder path.
      • Can also be a function that takes in a file and returns a folder path.
    • dirMode - Specify the mode the directory should be created with.

      • Default is the process mode.
  • Returns a Readable/Writable stream.

  • On write the stream will create a symbolic link (i.e. symlink) on disk at the folder/cwd specified.

  • After creating the symbolic link, it will be emitted from the stream so you can keep piping these around.

  • The file will be modified after being written to this stream:

    • cwd, base, and path will be overwritten to match the folder.

vinyl-fs's People

Contributors

ben-eb avatar ckross01 avatar davidbarrows avatar doowb avatar erikkemperman avatar hughsk avatar joachimgit avatar jonabrams avatar kevinwestern avatar kketch avatar klowner avatar lijunle avatar mathiasbynens avatar meroje avatar moshen avatar onkeltem avatar pgilad avatar phated avatar piranna avatar shinnn avatar silverwind avatar slife avatar stevemao avatar tomchentw avatar ultcombo avatar valeriangalliat avatar yocontra avatar yuvilio avatar

Watchers

 avatar  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.