Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including gulp-set-timestamp with all npm packages installed. Try it out:

var gulpSetTimestamp = require("gulp-set-timestamp")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

gulp-set-timestamp v0.1.0

Sets accessed and modified timestamps in files

gulp-set-timestamp

Sets accessed and modified timestamps in files after the file is written to its destination.

This is inspired by Bernd Matzner's gulp-touch-cmd but allows for passing in the date to be set. If you only need to update the timestamp to the current date/time, you may just want to use gulp-touch-cmd instead or pass in a new date (see examples).

Install

npm i gulp-set-timestamp or npm i --save-dev gulp-set-timestamp for a dev dependency.

Examples

Touch the File / Use Current Date

If dates are not passed, the current date/time will be used for both last accessed and last modified time. This is essentially the functionality that a touch provides.

let gulp = require('gulp'),
    setTimeStamp = require('gulp-set-timestamp');

gulp.task('default', () => {
    gulp.src('./src/**/*')
        .pipe(gulp.dest('./dest'))
        .pipe(setTimeStamp());
});

Use Date for Both Files

Sets a date for both last accessed and last modified.

let gulp = require('gulp'),
    setTimeStamp = require('gulp-set-timestamp');

gulp.task('default', () => {
    gulp.src('./src/**/*')
        .pipe(gulp.dest('./dest'))
        .pipe(setTimeStamp(new Date('2018-07-31T00:00:00'), new Date('2018-01-01T00:00:00')));
});

Misc Notes

I followed the gulp guidelines to create this plugin "the gulp way". If something is amiss, please open an issue, and I'll be happy to follow up.

Tests still need to be added.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free