使用Gulp较新版本的Gulp Vinyl FTP并未注意到文件中的更改,因此未部署UPDATE:时区问题 [英] 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指向"等/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软件包作为解决方案.那是两年前的事,所以让我知道你们是否有任何问题,或随时进行公关:)
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较新版本的Gulp Vinyl FTP并未注意到文件中的更改,因此未部署UPDATE:时区问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!