使用 Gulp newer 的 Gulp Vinyl FTP 没有注意到文件的变化,因此没有部署更新:时区问题 [英] Gulp Vinyl FTP using Gulp newer is not noticing changes in files and is therefore not deploying UPDATE: TIME ZONE ISSUE
问题描述
已解决:
我构建了一个 gulp 插件来解决这个问题...
I built a gulp plugin to solve the problem...
https://www.npmjs.com/package/gulp-mtime-correction
我遇到的问题是我使用 Vinyl-FTP 和 Gulp-Newer 的 gulp 任务似乎没有注意到我的文件中的更改,因此没有通过 FTP 发送更改.
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.
这里是 gulpfile.js 中的 FTP gulp 设置/任务
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 ) );
} );
由于我正在编写一个 wordpress 主题,FTPDirectoryPath 指向etc/wp-content/themes/themename"目录.我很确定它设置正确,因为它确实正确更新了全新的文件
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
我不知道这是 Vinyl-FTP 还是 Gulp-Newer 的问题,但由于某种原因,此 FTP 任务没有注意到 main.css 已更新.
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.
请帮忙!!
更新:
所以我发现这是一个时区问题.服务器在英国,但我在巴拿马(晚了 6 小时),所以服务器上的文件总是比 gulp-newer 更新(比较上次编辑时间),除非我没有更新它们6个小时.
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.
有没有人知道无需更改笔记本电脑时钟的解决方法?我可以在本地或服务器上手动更新文件的时间戳,还是有一个 gulp 扩展可以处理这个问题?
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?
谢谢!
推荐答案
我制作了这个 npm 包作为解决方案.那是两年前的事了,所以如果你们有任何问题,请告诉我,或者随时进行 PR :)
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 :)
您可以使用它来简单地调整文件的 mtime(上次修改时间)之前和之后检查您正在使用的任何新文件",使您看起来处于不同的时区.
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
这篇关于使用 Gulp newer 的 Gulp Vinyl FTP 没有注意到文件的变化,因此没有部署更新:时区问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!