gulp-file-sync

Sync file It keeps your files synced between two directory. In other words, any change of files in one directory will automatically take place in another one.

Installation npm install --save-dev gulp-file-sync Usage var gulp = require('gulp'), fileSync = require('gulp-file-sync'); gulp.task('sync', function() { gulp.watch(['src/*.*'], function() { fileSync('src', 'dest', {recursive: false}); }); }); API fileSync('source directory', 'destination directory', options) 'source directory' and 'destination directory'

type: String

Any change of files in 'source directory' will automatically take place in 'destination directory'.

options.recursive

type: Boolean

default: true

Synchronize subdirectories recursively.

options.ignore

type: string or array or regex or function

Either a string, array, regex, or function to exclude some specific files. For example:

// ignore all .log files fileSync('source directory', 'destination directory', { ignore: '.log' }) fileSync('source directory', 'destination directory', { ignore: [/^\.log$/i, '.cache'] // Exclude all .log and .cache files }) fileSync('source directory', 'destination directory', { ignore: /^\.log$/i }) fileSync('source directory', 'destination directory', { ignore: function(dir, file) { return file === '.log'; } }) options.addFileCallback

type: function(fullPathSrc, fullPathDest)

default:

var gutil = require('gulp-util'); function(fullPathSrc, fullPathDest) { gutil.log('同步增加文件到 ' + fullPathDest); }

This function is called when file was added on source directory.

fullPathSrc - is the path of file that was added on source directory. fullPathDest - is the path of file that was copied to destination directory. options.deleteFileCallback

type: function(fullPathSrc, fullPathDest)

default:

var gutil = require('gulp-util'); function(fullPathSrc, fullPathDest) { gutil.log('同步删除文件 ' + fullPathDest); }

This function is called when file was deleted on source directory.

fullPathSrc - is the path of file that was deleted on source directory. fullPathDest - is the path of file that was deleted on destination directory. options.updateFileCallback

type: function(fullPathSrc, fullPathDest)

default:

var gutil = require('gulp-util'); function(fullPathSrc, fullPathDest) { gutil.log('同步修改文件 ' + fullPathDest); }

This function is called when file was updated on source directory.

fullPathSrc - is the path of file that was updated on source directory. fullPathDest - is the path of file that was copied to destination directory. options.beforeAddFileCallback

type: function(fullPathSrc)

This function is called before file is added on source directory.

fullPathSrc - is the path of file that was added on source directory. options.beforeDeleteFileCallback

type: function(fullPathSrc)

This function is called before file is deleted on source directory.

fullPathSrc - is the path of file that was deleted on source directory. options.beforeUpdateFileCallback

type: function(fullPathSrc)

This function is called before file is updated on source directory.

fullPathSrc - is the path of file that was updated on source directory. Changelog License

MIT (c) 2015 Kayo Lee ( [email protected] )

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

主题: Gulp删除
分页:12
转载请注明
本文标题:可以进行完整文件操作同步(增加、删除、更新)的 Gulp 插件
本站链接:http://www.codesec.net/view/484464.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(86)