gulp-changed
Advanced tools
Comparing version 3.0.0 to 3.1.0
20
index.js
'use strict'; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const crypto = require('crypto'); | ||
const gutil = require('gulp-util'); | ||
@@ -23,4 +22,2 @@ const through = require('through2'); | ||
const sha1 = buf => crypto.createHash('sha1').update(buf).digest('hex'); | ||
// Only push through files changed more recently than the destination files | ||
@@ -36,17 +33,9 @@ function compareLastModifiedTime(stream, sourceFile, targetPath) { | ||
// Only push through files with different SHA1 than the destination files | ||
function compareSha1Digest(stream, sourceFile, targetPath) { | ||
// Only push through files with different contents than the destination files | ||
function compareContents(stream, sourceFile, targetPath) { | ||
return readFile(targetPath) | ||
.then(targetData => { | ||
if (sourceFile.isNull()) { | ||
if (sourceFile.isNull() || !sourceFile.contents.equals(targetData)) { | ||
stream.push(sourceFile); | ||
return; | ||
} | ||
const sourceDigest = sha1(sourceFile.contents); | ||
const targetDigest = sha1(targetData); | ||
if (sourceDigest !== targetDigest) { | ||
stream.push(sourceFile); | ||
} | ||
}); | ||
@@ -93,2 +82,3 @@ } | ||
module.exports.compareLastModifiedTime = compareLastModifiedTime; | ||
module.exports.compareSha1Digest = compareSha1Digest; | ||
module.exports.compareContents = compareContents; | ||
module.exports.compareSha1Digest = compareContents; |
{ | ||
"name": "gulp-changed", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Only pass through changed files", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -95,3 +95,4 @@ # gulp-changed [![Build Status](https://travis-ci.org/sindresorhus/gulp-changed.svg?branch=master)](https://travis-ci.org/sindresorhus/gulp-changed) | ||
- `changed.compareLastModifiedTime` | ||
- `changed.compareSha1Digest` | ||
- `changed.compareContents` | ||
- `changed.compareSha1Digest` (Deprecated) | ||
@@ -103,3 +104,3 @@ ###### Example | ||
gulp.src('src/**/*.jade') | ||
.pipe(changed('app', {hasChanged: changed.compareSha1Digest})) | ||
.pipe(changed('app', {hasChanged: changed.compareContent})) | ||
.pipe(jade()) | ||
@@ -106,0 +107,0 @@ .pipe(gulp.dest('app')) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
141
8236
67