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

gulp-rev-timestamp

v0.0.1

Published

Appends a timestamp to query string

Downloads

892

Readme

Install

$ npm install --save gulp-rev-timestamp

Why another plugin?

This plugin is based on gulp-rev-append which is very good and in some cases even better, because it relies on file hash, so if file didn't change between versions, the hash will remain the same so file can stay in cache.

gulp-rev-timestamp provides you an option to either read your file and generate a hash out of it what rev-append does or just generate a hash(timestamp or revision) and replace the query string every time regardless of file being changed or not. This way regardless of file contents changes or not, you have a new query string every time appended to file. This is bit faster than the first option, as it does not require to read the contents of file every time and generate a hash based on it.

RegularExpression

var FILE_DECL = /(?:href=|src=|url\()['|"]([^\s>"']+?)\?rev=([^\s>"']+?)['|"]/gi;

Usage

We can use gulp-rev-timestamp to cache-bust several assets and generate timestamp or hash or revision.

var gulp = require('gulp');
var revts = require('gulp-rev-timestamp');

gulp.task('rev-timestamp', function() {
  gulp.src("index.html")
    .pipe(revts())
    .pipe(gulp.dest('.'))
});


### Options

#### default

With no optional parameter sent, the strict mode would false, mode would be type of timestamp.

```js
var gulp = require('gulp');
var revts = require('gulp-rev-timestamp');

gulp.task('rev-timestamp', function() {
  gulp.src("index.html")
    .pipe(revts({strict: true}))
    .pipe(gulp.dest('.'))
});

The above task would replace any

<!-- Minified Files -->
<script src="../path/config.min.js?rev=@@hash"></script>
<script src="../path/app.min.js?rev=@@hash"></script>
<script src="../path/serivices.min.js?rev=@@hash"></script>
<!-- Minified Files -->

to below with a hash of timestamp, regardless of file being changed or not:

<!-- Minified Files -->
<script src="../path/config.min.js?rev=1e7aa69df74343571bf4977b685cb496"></script>
<script src="../path/app.min.js?rev=1ed8a9d8c7aa5de44043ca86e9624248"></script>
<script src="../path/serivices.min.js?rev=341a3c405f3445e8a0d908ff1a4542ab"></script>
<!-- Minified Files -->

strict

Type : Boolean Default: false

You set a flag, strict, which will check if the file exist in relative path and also generate a hash and append to query string only if file content has changed. Default value is false.

var gulp = require('gulp');
var revts = require('gulp-rev-timestamp');

gulp.task('rev-timestamp', function() {
  gulp.src("index.html")
    .pipe(revts({strict: true}))
    .pipe(gulp.dest('.'))    
});

The above task would replace any

```sh
<!-- Minified Files -->
<script src="../path/config.min.js?rev=@@hash"></script>
<script src="../path/app.min.js?rev=@@hash"></script>
<script src="../path/serivices.min.js?rev=@@hash"></script>
<!-- Minified Files -->

to below with a hash of content of file only if the file content has changed:

<!-- Minified Files -->
<script src="../path/config.min.js?rev=51dc1baa4a2dac96097d56de62d860a3"></script>
<script src="../path/app.min.js?rev=7a5a2adc42842b0e2b317440cdc2957f"></script>
<script src="../path/serivices.min.js?rev=46abc154eb09e362ad9ae4f7e69868dc"></script>
<!-- Minified Files -->

mode

Type : String Default: timestamp

Specifies the type of hash you would like to append to your query string (timestamp or revision)

var gulp = require('gulp');
var revts = require('gulp-rev-timestamp');

gulp.task('rev-timestamp', function() {
  gulp.src("index.html")
    .pipe(revts({strict: false, mode: 'timestamp'}))
    .pipe(gulp.dest('.'))
});

When mode => revision

var gulp = require('gulp');
var revts = require('gulp-rev-timestamp');

gulp.task('rev-timestamp', function() {
  gulp.src("index.html")
    .pipe(revts({strict: false, mode: 'revision', revision: '55'}))
    .pipe(gulp.dest('.'))
});

The above task would replace any

```sh
<!-- Minified Files -->
<script src="../path/config.min.js?rev=@@hash"></script>
<script src="../path/app.min.js?rev=@@hash"></script>
<script src="../path/serivices.min.js?rev=@@hash"></script>
<!-- Minified Files -->

to below with a revision, preferrably coming from svn repo global version also does not check whether the contents of file has been changed or not:

<!-- Minified Files -->
<script src="../path/config.min.js?rev=55"></script>
<script src="../path/app.min.js?rev=55"></script>
<script src="../path/serivices.min.js?rev=55"></script>
<!-- Minified Files -->

License

MIT © [Vinoth Babu]