Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

floatdrop/gulp-watch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-watch NPM version Build Status Coverage Status Dependency Status

File watcher, that uses super-fast chokidar and emits vinyl objects.

Installation

Run npm install gulp-watch.

Usage

var gulp = require('gulp'),
    watch = require('gulp-watch');

gulp.task('default', function () {
    watch('css/**/*.css')
        .pipe(gulp.dest('./build/'));
});

Protip: until gulpjs 4.0 is released, you can use gulp-plumber to prevent stops on errors.

More examples can be found in docs/readme.md.

API

watch(glob, [options, callback])

Creates watcher that will spy on files that were matched by glob which can be a node-glob string or array of strings.

Returns pass through stream, that will emit vinyl files (with additional event property) that corresponds to event on file-system.

Callback function(vinyl)

This function is called, when some events is happens on file-system. All incoming files that piped in will be grouped and passed to events stream as is.

  • vinyl — is vinyl object that corresponds to file that caused event. Additional event field is added to determine, what caused changes.

Possible events:

  • add - file was added to watch or created
  • change - file was changed
  • unlink - file was deleted

Options

This object is passed to chokidar options directly. Options for gulp.src are also available. If you do not want content from watch, then add read: false to the options object.

options.events

Type: Array
Default: ['add', 'change', 'unlink']

List of events, that should be watched by gulp-watch. Contains event names from chokidar.

options.base

Type: String
Default: undefined

Use explicit base path for files from glob. Read more about base and cwd in gulpjs docs.

options.name

Type: String
Default: undefined

Name of the watcher. If it present in options, you will get more readable output.

options.verbose

Type: Boolean
Default: false

This options will enable verbose output.

Methods

Returned Stream from constructor have some useful methods:

  • add(path / paths)
  • unwatch(path / paths)
  • close()

Events

  • end
  • ready
  • error

License

MIT (c) 2014 Vsevolod Strukchinsky ([email protected])

About

Watch, that actually is an endless stream

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 33