Archive. Date of access: 12 Jan 2022

Marak 64fbc2a0c5 first commit 10 years ago
examples 64fbc2a0c5 first commit 10 years ago
test 64fbc2a0c5 first commit 10 years ago
.gitignore 64fbc2a0c5 first commit 10 years ago
README.md 64fbc2a0c5 first commit 10 years ago
index.js 64fbc2a0c5 first commit 10 years ago
package.json 64fbc2a0c5 first commit 10 years ago

README.md

vinyl-diff

Unreleased v0.0.0

Information

Packagevinyl-diff
Description Perform diffs of vinyl streams
Node Version >= 0.10

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