0.0.0 • Published 10 years ago

vinyl-diff v0.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
10 years ago

vinyl-diff

Unreleased v0.0.0

Information

Purpose

This library allows you to perform diffs between streams of vinyl.

This enables the ability to only push vinyl files that have changed down the stream.

All vinyl-adapters are compatible with this module.

Alternatives to using this module could be gulp-changed, but gulp-changed is bound to the file-system and unable to compare arbitrary vinyl streams.

Usage

Only use changed files

var changed = require('../index').changed;
var vfs = require('vinyl-fs');
var map = require('map-stream');

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

vfs.src('./test/fixtures/new-files/**')
 .pipe(map(log))
 .pipe(changed(vfs.src('./test/fixtures/old-files/**'), { compare: "sha", dest: "old-files"}))
 .pipe(map(log));

Only use files with newer mtime

var changed = require('../index').changed;
var vfs = require('vinyl-fs');
var map = require('map-stream');

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

vfs.src('./test/fixtures/new-files/**')
 .pipe(map(log))
 .pipe(changed(vfs.src('./test/fixtures/old-files/**'), { compare: "mtime", dest: "old-files"}))
 .pipe(map(log));

API

changed(stream, ,opt)

  • Takes a vinyl stream as the first argument.
  • Possible options for the second argument:
  • compare - property to compare for changes. Default is sha. Also available: mtime
  • dest - destination to compare new files against
  • Returns a Readable/Writable stream.
  • This stream emits matching vinyl File objects