npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp3-last-run

v0.1.0

Published

An implementation of Gulp 4.x's `lastRun` method for Gulp 3.x.

Downloads

25

Readme

Gulp 3 Last Run

An implementation of Gulp 4.x's lastRun method for Gulp 3.x.

This is a utility, not a plugin. It does not act on files or streams nor does it meet other requirements defined by Gulp to be considered a plugin.

Why?

To take advantage of a helpful feature from Gulp 4.x without waiting for it to be released or upgrading from 3.x to 4.x. The original intent is to provide a timestamp value that can be used for filtering.

Installation

npm install --save-dev gulp3-last-run

Usage

Use Gulp 3 Last Run in combination with gulp-filter-since:

const gulp = require('gulp');
const gulp3LastRun = require('gulp3-last-run');
const gulpLoadPlugins = require('gulp-load-plugins');

const $ = gulpLoadPlugins();
const taskLastRun = gulp3LastRun(gulp);

gulp.task('scripts', function(){
  const lastRunMs = taskLastRun.retrieveThenCapture('scripts');
  return gulp.src('app/scripts/**/*.js')
    .pipe($.filterSince(lastRunMs))
    .pipe($.babel())
    .pipe(gulp.dest('dist/scripts'))
  ;
});

gulp.task('watch', ['scripts'], function(){
  gulp.watch('app/scripts/**/*.js', ['scripts']);
});

or, use it in combination with vinyl-filter-since and gulp-if:

const gulp = require('gulp');
const gulp3LastRun = require('gulp3-last-run');
const gulpLoadPlugins = require('gulp-load-plugins');
const vinylFilterSince = require('vinyl-filter-since');

const $ = gulpLoadPlugins();
const taskLastRun = gulp3LastRun(gulp);

gulp.task('scripts', function(){
  const lastRunMs = taskLastRun.retrieveThenCapture('scripts');
  return gulp.src('app/scripts/**/*.js')
    .pipe($.if(!!lastRunMs, vinylFilterSince(lastRunMs)))
    .pipe($.babel())
    .pipe(gulp.dest('dist/scripts'))
  ;
});

gulp.task('watch', ['scripts'], function(){
  gulp.watch('app/scripts/**/*.js', ['scripts']);
});

API

gulp3LastRun(gulpInstance)

Returns a plain object containing static methods that act on a reference to a gulp object to get and set last run times. It is basically a wrapper for the last-run module.

gulpInstance

Type: Object

A reference to the gulp module.

taskLastRun.retrieveThenCapture(taskName[, options])

retrieveThenCapture is a convenience method not found in the last-run module. It executes the retrieve method then the capture method with a single method call.

  1. Retrieves the current last run for a given task, as a number representing milliseconds.
  2. Immediately captures a new last run time
  3. Returns the retrieved last run value (whatever it was before the capture). Returns undefined if the task function has not been previously captured.

taskName

Type: String

A string that is used to retrieve the task function from the gulp instance. The task function is then used as the fn argument for last-run module method arguments.

options

Type: Object

Options for each method can be provided as option and will be passed to their respective last-run methods if provided.

options.retrieveTimeResolution

Type: Number

Assuming lastRun(fn) returns 1426000001111, lastRun(fn, 1000) returns 1426000001000.

Source: lastRun(fn, [timeResolution]) => [Timestamp]

options.captureTimestamp

Type: Number

If passed the optional timestamp, captures that time instead of Date.now(). The captured timestamp can then be retrieved using the lastRun function.

Source: lastRun.capture(fn, [timestamp])

taskLastRun.capture(taskName[, timestamp]), taskLastRun.release(taskName), and taskLastRun.retrieve(taskName[, timeResolution])

taskName

Type: String

A string that is used to retrieve the task function from the gulp instance. The task function is then used as the fn argument for last-run module method arguments.

(other arguments)

Other arguments are passed directly to their last-run module counterparts. gulp3-last-run's retrieve method is the counter part for last-run's main method.

See last-run's API documentation for more information about each of these methods.