Socket
Socket
Sign inDemoInstall

gulp-newer

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-newer - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

spec.js

12

index.js

@@ -66,3 +66,5 @@ var Transform = require('stream').Transform;

// wait to see if any are newer, then pass through all
self._bufferedFiles = [];
if (!self._bufferedFiles) {
self._bufferedFiles = [];
}
return Q.resolve(destStats);

@@ -105,11 +107,7 @@ }

/**
* Flush out any remaining buffered files.
* Remove references to buffered files.
* @param {function(Error)} done Callback.
*/
Newer.prototype._flush = function(done) {
if (this._bufferedFiles) {
this._bufferedFiles.forEach(function(file) {
this.push(file);
}, this);
}
this._bufferedFiles = null;
done();

@@ -116,0 +114,0 @@ };

{
"name": "gulp-newer",
"version": "0.1.0",
"version": "0.2.0",
"description": "Only pass through newer source files",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/tschaub/gulp-newer",

# `gulp-newer`
A gulp plugin for passing through only those source files that are newer than corresponding destination files.
A [Gulp](http://gulpjs.com/) plugin for passing through only those source files that are newer than corresponding destination files.

@@ -11,4 +11,8 @@ ## Install

## Use
## Example
### Using `newer` with 1:1 source:dest mappings
The default task in the example below sets up a watch that minifies images on changes. Piping the source files to `newer` before `imagemin` ensures that only those images that have changed are minified. The `newer` plugin is configured with the directory path for minified images.
```js

@@ -19,24 +23,57 @@ var gulp = require('gulp');

var imgSrc = 'src/img/**';
var imgDest = 'build/img';
// Minify any new images
gulp.task('images', function() {
var imgSrc = 'src/img/**';
var imgDest = 'build/img';
// Add the newer pipe to pass through newer images only
return gulp.src(imgSrc)
// only pass through newer images
.pipe(newer(dest))
.pipe(newer(imgDest))
.pipe(imagemin())
.pipe(gulp.dest(dest));
.pipe(gulp.dest(imgDest));
});
gulp.task('default', function() {
gulp.watch(imgSrc, function() {
gulp.run('images');
});
});
```
### Using `newer` with many:1 source:dest mappings
Plugins like `gulp-concat` take many source files and generate a single destination file. In this case, the `newer` stream will pass through *all* source files if *any one* of them is newer than the destination file. The `newer` plugin is configured with the destination file path.
```js
var gulp = require('gulp');
var newer = require('gulp-newer');
var concat = require('gulp-concat');
// Concatenate all if any are newer
gulp.task('concat', function() {
// Add the newer pipe to pass through all sources if any are newer
return gulp.src('lib/*.js')
.pipe(newer('dist/all.js'))
.pipe(concat('all.js'))
.pipe(gulp.dest('dist'));
});
```
## API
### `newer(dest)`
* **dest** - `string` Path to destination directory or file.
Create a [transform stream](http://nodejs.org/api/stream.html#stream_class_stream_transform_1) that passes through files whose modification time is more recent than the corresponding destination file's modification time.
If `dest` is a directory path, the `newer` stream will check for files in the destination directory with the same relative path as source files. Source files that have been modified more recently than the resolved destination file will be passed through. If the `dest` directory or resolved destination file does not exist, all source files will be passed through.
If `dest` is a file path, the `newer` stream will pass through *all* files if *any one* of them has been modified more recently than the destination file. If the `dest` file does not exist, all source files will be passed through.
[![Current Status](https://secure.travis-ci.org/tschaub/gulp-newer.png?branch=master)](https://travis-ci.org/tschaub/gulp-newer)
var path = require('path');
var jshint = require('jshint/src/cli').run;
var glob = require('glob');
var Mocha = require('mocha');
/**

@@ -12,3 +12,3 @@ * Run the linter.

exports.lint = function(done) {
var args = ['index.js', 'tasks.js', 'test'];
var args = ['index.js', 'tasks.js', 'spec.js'];
var passed = jshint({args: args});

@@ -29,5 +29,3 @@ process.nextTick(function() {

mocha.ui('bdd');
mocha.files = glob.sync('test/**/*.spec.js').map(function(file) {
return path.resolve(file);
});
mocha.files = [path.resolve('spec.js')];
mocha.run(function(failures) {

@@ -34,0 +32,0 @@ done(failures ? new Error('Mocha failures') : null);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc