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

可紊 提交于 2019-12-06 05:54:45

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/45725528/gulp-vinyl-ftp-using-gulp-newer-is-not-noticing-changes-in-files-and-is-therefor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!