• Stars
    star
    227
  • Rank 175,900 (Top 4 %)
  • Language
    JavaScript
  • Created almost 11 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pass through newer source files only

gulp-newer

A Gulp plugin for passing through only those source files that are newer than corresponding destination files.

Install

npm install gulp-newer --save-dev

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.

var gulp = require('gulp');
var newer = require('gulp-newer');
var imagemin = require('gulp-imagemin');

var imgSrc = 'src/img/**';
var imgDest = 'build/img';

// Minify any new images
gulp.task('images', function() {

  // Add the newer pipe to pass through newer images only
  return gulp.src(imgSrc)
      .pipe(newer(imgDest))
      .pipe(imagemin())
      .pipe(gulp.dest(imgDest));

});

gulp.task('default', function() {
  gulp.watch(imgSrc, ['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.

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.

newer(options)

  • options.dest - string As above, required.
  • options.ext - string Source files will be matched to destination files with the provided extension (e.g. '.css').
  • options.map - function Map relative source paths to relative destination paths (e.g. function(relativePath) { return relativePath + '.bak'; })
  • options.extra - string or array An extra file, file glob, or list of extra files and/or globs, to check for updated time stamp(s). If any of these files are newer than the destination files, then all source files will be passed into the stream.
  • options.ctime - boolean Source files will be matched to destination files based on ctime rather than mtime.

Create a transform stream 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.

By default, the newer stream will check files' modification time, or mtime, which updates when the file contents are changed. If ctime is true, files' change time will be checked instead, which updates when file contents or attributes like the file name or permissions have changed.

Current Status

More Repositories

1

gh-pages

General purpose task for publishing files to a gh-pages branch on GitHub
JavaScript
3,090
star
2

grunt-newer

Configure Grunt tasks to run with newer files only.
JavaScript
949
star
3

mock-fs

Configurable mock for the fs module
JavaScript
906
star
4

grunt-gh-pages

Publish to GitHub pages with Grunt
JavaScript
336
star
5

projzh

Projection utilities for working with Baidu maps
JavaScript
83
star
6

authorized

Action based authorization middleware.
JavaScript
59
star
7

es-main

Test if an ES module is run directly (require.main replacement)
JavaScript
58
star
8

karma-source-map-support

Karma plugin for inline sourcemap support
JavaScript
33
star
9

karma-phantomjs-shim

Provides shims when running tests in PhantomJS 1.x.
JavaScript
32
star
10

github-changelog

Create a simple changelog based on GitHub activity
JavaScript
28
star
11

mapjack

Map based editing of GeoJSON files on GitHub
JavaScript
22
star
12

pixelworks

âš™ Utilities for working with image data
JavaScript
16
star
13

stickymap

Sticky maps
JavaScript
14
star
14

ol-hashed

Maintain your map view's state in the URL hash
JavaScript
8
star
15

hashed

Serialize state from multiple providers using location.hash
JavaScript
8
star
16

jwt-claims

Minimal utility for decoding JWT claims
JavaScript
7
star
17

nik

Create a new package based on an existing one
JavaScript
5
star
18

wps-demo

OpenLayers Examples Using GeoServer's WPS
JavaScript
4
star
19

jugl

Jugl JavaScript Template Library
JavaScript
4
star
20

bitgeo

JavaScript
3
star
21

lightcycle

Remake of an 80s classic.
JavaScript
3
star
22

get-down

Download and optionally extract files
JavaScript
3
star
23

gitstatic

Make static websites with GitHub webhooks
JavaScript
3
star
24

F4GNA12-OL

FOSS4G NA 2012 OpenLayers Presentation
JavaScript
3
star
25

tilet

A demonstration tiled map client
JavaScript
3
star
26

geofunc

Functions for working with GeoJSON
JavaScript
2
star
27

static

Skeleton for static sites
Shell
2
star
28

thehoneybadger

Hungy, fearless, gross
JavaScript
2
star
29

doctest

Providing testfile and testmod methods for Rhino's doctest.
JavaScript
2
star
30

css-asset-rebaser

Copies assets from node_modules and rewrites URLs in CSS
JavaScript
2
star
31

kinda

JavaScript
2
star
32

ol3-video

Inspired by Mapbox's GL video demo
JavaScript
2
star
33

tiles

JavaScript
1
star
34

jsdoc-json

Template for JSDoc that outputs JSON
JavaScript
1
star
35

packajs

Build utility and debug server for Bower packages
JavaScript
1
star
36

bench-it

Benchmark your code
JavaScript
1
star
37

demo

A few demos
JavaScript
1
star
38

urel

Get the relative URL between two root-relative URLs
JavaScript
1
star
39

test-go-swagger

Makefile
1
star
40

suite

OpenGeo Suite Git Repository
JavaScript
1
star
41

restbin

App for examining HTTP requests.
JavaScript
1
star
42

pgfs

Postgres backed WFS 3
Go
1
star
43

karma-polyfill

Load polyfills from polyfill.io before running Karma tests
JavaScript
1
star
44

ol-raster

Raster sources for OL3
JavaScript
1
star
45

test-metalsmith-layouts

Testing partials with metalsmith-layouts
HTML
1
star
46

limited

Golang x/sync/errgroup like functionality with limits
Go
1
star
47

geoserver-geoscript-js

GeoScript extension for GeoScript JS
Java
1
star