Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gulp Vinyl FTP using Gulp newer is not noticing changes in files and is therefore not deploying UPDATE: TIME ZONE ISSUE

RESOLVED:

I built a gulp plugin to solve the problem...

https://www.npmjs.com/package/gulp-mtime-correction


The issue I'm having is that my gulp task using Vinyl-FTP and Gulp-Newer doesn't seem to be noticing changes in my files and therefore is not sending the changes via FTP.

So here are the FTP gulp settings/tasks in gulpfile.js

// FTP settings
const FTP = {
    connOpts : {
        host        : 'ftp.****.co.uk',
        user        : '****',
        password    : '*****',
        parallel    : 10,
        log         : gutil.log
    },
    directoryPath : FTPDirectoryPath,
    src           : dir.build + '**/*',
    base          : dir.build
};

// ftp deployment to live site
gulp.task( 'deploy', () => {

    var conn = ftp.create( FTP.connOpts );

    return gulp.src( FTP.src , { base: FTP.base, buffer: false } )
        .pipe( conn.newer( FTP.directoryPath ) ) // only upload newer files 
        .pipe( conn.dest( FTP.directoryPath ) );
} );

Since I'm writing a wordpress theme, FTPDirectoryPath points to the 'etc/wp-content/themes/themename' directory. I'm pretty sure it's set right because it does correctly update brand new files

I don't know if it's an issue with Vinyl-FTP or with Gulp-Newer, but for some reason this FTP task doesn't notice that main.css has been updated.

Please help!!

UPDATE:

So I've worked out that this is a timezone issue. The server is in the UK, but I'm in Panama (6 hours behind), so the files on the server will always appear newer to gulp-newer (which compares the last edit time) unless I haven't updated them for over 6 hours.

Does anyone know of a workaround for this without having to change the clock on my laptop? Can I manually update timestamps on files either locally or on the server, or is there a gulp extension that can deal with this?

Thanks!

like image 593
Matt Wills Avatar asked Nov 07 '22 18:11

Matt Wills


1 Answers

I made this npm package as a solution. It was 2 years ago, so let me know if you guys have any issues with it, or feel free to make a PR :)

You can use it to simply adjust a file's mtime (last modification time) before and after whatever 'is file new' check youre using, making it appear that you're in a different timezone.

https://www.npmjs.com/package/gulp-mtime-correction

like image 50
Matt Wills Avatar answered Nov 15 '22 13:11

Matt Wills