I have gulp task below and with every run of this task (before browsersync) I want to change last modification time of one file (nothing changes in that file, I just need to change time of last modification - alternative to shell "touch" command). Can somebody tell me what's the easiest way to do that please? Thanks!
gulp.task('sass', function() {
return sass(pkg.sass.dir, {sourcemap: true, precision: 10})
.on('error', function (err) {
onError(err);
})
.pipe(autoprefixer({
browsers: ['last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'],
cascade: true
}))
.pipe(gulp.dest(pkg.css.dir))
.pipe(browsersync.reload({stream:true}));
});
Use the core fs
module's fs.utimes function, which is the node analog to the Unix touch
command. You pass the path and if you pass a new Date()
as the mtime
parameter, that should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With