node-gulp-4.0.2+~cs38.20.35/000077500000000000000000000000001415667007300150405ustar00rootroot00000000000000node-gulp-4.0.2+~cs38.20.35/.editorconfig000066400000000000000000000003261415667007300175160ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true end_of_line = lf [*.md] trim_trailing_whitespace = false node-gulp-4.0.2+~cs38.20.35/.eslintrc000066400000000000000000000000301415667007300166550ustar00rootroot00000000000000{ "extends": "gulp" } node-gulp-4.0.2+~cs38.20.35/.gitattributes000066400000000000000000000000161415667007300177300ustar00rootroot00000000000000* text eol=lf node-gulp-4.0.2+~cs38.20.35/.github/000077500000000000000000000000001415667007300164005ustar00rootroot00000000000000node-gulp-4.0.2+~cs38.20.35/.github/support.yml000066400000000000000000000001421415667007300206340ustar00rootroot00000000000000# Configuration for support-requests - https://github.com/dessant/support-requests _extends: gulp node-gulp-4.0.2+~cs38.20.35/.jscsrc000066400000000000000000000000271415667007300163270ustar00rootroot00000000000000{ "preset": "gulp" } node-gulp-4.0.2+~cs38.20.35/.travis.yml000066400000000000000000000002241415667007300171470ustar00rootroot00000000000000sudo: false language: node_js node_js: - '14' - '12' - '10' - '8' - '6' - '4' - '0.12' - '0.10' after_script: - npm run coveralls node-gulp-4.0.2+~cs38.20.35/LICENSE000077500000000000000000000022141415667007300160470ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2017 Blaine Bublitz , Eric Schoffstall and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. node-gulp-4.0.2+~cs38.20.35/README.md000066400000000000000000000126451415667007300163270ustar00rootroot00000000000000

# glob-watcher [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url] Watch globs and execute a function upon change, with intelligent defaults for debouncing and queueing. ## Usage ```js var watch = require('glob-watcher'); watch(['./*.js', '!./something.js'], function(done){ // This function will be called each time a globbed file is changed // but is debounced with a 200ms delay (default) and queues subsequent calls // Make sure to signal async completion with the callback // or by returning a stream, promise, observable or child process done(); // if you need access to the `path` or `stat` object, listen // for the `change` event (see below) // if you need to listen to specific events, use the returned // watcher instance (see below) }); // Raw chokidar instance var watcher = watch(['./*.js', '!./something.js']); // Listen for the 'change' event to get `path`/`stat` // No async completion available because this is the raw chokidar instance watcher.on('change', function(path, stat) { // `path` is the path of the changed file // `stat` is an `fs.Stat` object (not always available) }); // Listen for other events // No async completion available because this is the raw chokidar instance watcher.on('add', function(path, stat) { // `path` is the path of the changed file // `stat` is an `fs.Stat` object (not always available) }); ``` ## API ### `watch(globs[, options][, fn])` Takes a path string, an array of path strings, a [glob][micromatch] string or an array of [glob][micromatch] strings as `globs` to watch on the filesystem. Also optionally takes `options` to configure the watcher and a `fn` to execute when a file changes. __Note: As of 5.0.0, globs must use `/` as the separator character because `\\` is reserved for escape sequences (as per the Bash 4.3 & Micromatch specs). This means you can't use `path.join()` or `__dirname` in Windows environments. If you need to use `path.join()`, you can use [normalize-path][normalize-path] against your paths afterwards. If you need to use `__dirname`, you can set it as the `cwd` option that gets passed directly to [chokidar][chokidar]. The [micromatch docs][micromatch-backslashes] contain more information about backslashes.__ Returns an instance of [chokidar][chokidar]. #### `fn([callback])` If the `fn` is passed, it will be called when the watcher emits a `change`, `add` or `unlink` event. It is automatically debounced with a default delay of 200 milliseconds and subsequent calls will be queued and called upon completion. These defaults can be changed using the `options`. The `fn` is passed a single argument, `callback`, which is a function that must be called when work in the `fn` is complete. Instead of calling the `callback` function, [async completion][async-completion] can be signalled by: * Returning a `Stream` or `EventEmitter` * Returning a `Child Process` * Returning a `Promise` * Returning an `Observable` Once async completion is signalled, if another run is queued, it will be executed. #### `options` ##### `options.ignoreInitial` If set to `false` the `fn` is called during [chokidar][chokidar] instantiation as it discovers the file paths. Useful if it is desirable to trigger the `fn` during startup. __Passed through to [chokidar][chokidar], but defaulted to `true` instead of `false`.__ Type: `Boolean` Default: `true` ##### `options.delay` The delay to wait before triggering the `fn`. Useful for waiting on many changes before doing the work on changed files, e.g. find-and-replace on many files. Type: `Number` Default: `200` (milliseconds) ##### `options.queue` Whether or not a file change should queue the `fn` execution if the `fn` is already running. Useful for a long running `fn`. Type: `Boolean` Default: `true` ##### `options.events` An event name or array of event names to listen for. Useful if you only need to watch specific events. Type: `String | Array` Default: `[ 'add', 'change', 'unlink' ]` ##### other Options are passed directly to [chokidar][chokidar]. ## License MIT [micromatch]: https://github.com/micromatch/micromatch [normalize-path]: https://www.npmjs.com/package/normalize-path [micromatch-backslashes]: https://github.com/micromatch/micromatch#backslashes [async-completion]: https://github.com/gulpjs/async-done#completion-and-error-resolution [chokidar]: https://github.com/paulmillr/chokidar [downloads-image]: http://img.shields.io/npm/dm/glob-watcher.svg [npm-url]: https://npmjs.com/package/glob-watcher [npm-image]: http://img.shields.io/npm/v/glob-watcher.svg [travis-url]: https://travis-ci.org/gulpjs/glob-watcher [travis-image]: http://img.shields.io/travis/gulpjs/glob-watcher.svg?label=travis-ci [appveyor-url]: https://ci.appveyor.com/project/gulpjs/glob-watcher [appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/glob-watcher.svg?label=appveyor [coveralls-url]: https://coveralls.io/r/gulpjs/glob-watcher [coveralls-image]: http://img.shields.io/coveralls/gulpjs/glob-watcher/master.svg [gitter-url]: https://gitter.im/gulpjs/gulp [gitter-image]: https://badges.gitter.im/gulpjs/gulp.png node-gulp-4.0.2+~cs38.20.35/appveyor.yml000066400000000000000000000010421415667007300174250ustar00rootroot00000000000000# http://www.appveyor.com/docs/appveyor-yml # http://www.appveyor.com/docs/lang/nodejs-iojs environment: matrix: # node.js - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "4" - nodejs_version: "6" - nodejs_version: "8" - nodejs_version: "10" - nodejs_version: "12" - nodejs_version: "14" install: - ps: Install-Product node $env:nodejs_version - npm install test_script: - node --version - npm --version - cmd: npm test build: off # build version format version: "{build}" node-gulp-4.0.2+~cs38.20.35/index.js000066400000000000000000000065501415667007300165130ustar00rootroot00000000000000'use strict'; var chokidar = require('chokidar'); var debounce = require('just-debounce'); var asyncDone = require('async-done'); var defaults = require('object.defaults/immutable'); var isNegatedGlob = require('is-negated-glob'); var anymatch = require('anymatch'); var normalize = require('normalize-path'); var defaultOpts = { delay: 200, events: ['add', 'change', 'unlink'], ignored: [], ignoreInitial: true, queue: true, }; function listenerCount(ee, evtName) { if (typeof ee.listenerCount === 'function') { return ee.listenerCount(evtName); } return ee.listeners(evtName).length; } function hasErrorListener(ee) { return listenerCount(ee, 'error') !== 0; } function exists(val) { return val != null; } function watch(glob, options, cb) { if (typeof options === 'function') { cb = options; options = {}; } var opt = defaults(options, defaultOpts); if (!Array.isArray(opt.events)) { opt.events = [opt.events]; } if (Array.isArray(glob)) { // We slice so we don't mutate the passed globs array glob = glob.slice(); } else { glob = [glob]; } var queued = false; var running = false; // These use sparse arrays to keep track of the index in the // original globs array var positives = new Array(glob.length); var negatives = new Array(glob.length); // Reverse the glob here so we don't end up with a positive // and negative glob in position 0 after a reverse glob.reverse().forEach(sortGlobs); function sortGlobs(globString, index) { var result = isNegatedGlob(globString); if (result.negated) { negatives[index] = result.pattern; } else { positives[index] = result.pattern; } } var toWatch = positives.filter(exists); function joinCwd(glob) { if (glob && opt.cwd) { return normalize(opt.cwd + '/' + glob); } return glob; } // We only do add our custom `ignored` if there are some negative globs // TODO: I'm not sure how to test this if (negatives.some(exists)) { var normalizedPositives = positives.map(joinCwd); var normalizedNegatives = negatives.map(joinCwd); var shouldBeIgnored = function(path) { var positiveMatch = anymatch(normalizedPositives, path, true); var negativeMatch = anymatch(normalizedNegatives, path, true); // If negativeMatch is -1, that means it was never negated if (negativeMatch === -1) { return false; } // If the negative is "less than" the positive, that means // it came later in the glob array before we reversed them return negativeMatch < positiveMatch; }; opt.ignored = [].concat(opt.ignored, shouldBeIgnored); } var watcher = chokidar.watch(toWatch, opt); function runComplete(err) { running = false; if (err && hasErrorListener(watcher)) { watcher.emit('error', err); } // If we have a run queued, start onChange again if (queued) { queued = false; onChange(); } } function onChange() { if (running) { if (opt.queue) { queued = true; } return; } running = true; asyncDone(cb, runComplete); } var fn; if (typeof cb === 'function') { fn = debounce(onChange, opt.delay); } function watchEvent(eventName) { watcher.on(eventName, fn); } if (fn) { opt.events.forEach(watchEvent); } return watcher; } module.exports = watch; node-gulp-4.0.2+~cs38.20.35/package.json000066400000000000000000000024051415667007300173270ustar00rootroot00000000000000{ "name": "glob-watcher", "version": "5.0.5", "description": "Watch globs and execute a function upon change, with intelligent defaults for debouncing and queueing.", "author": "Gulp Team (http://gulpjs.com/)", "contributors": [], "repository": "gulpjs/glob-watcher", "license": "MIT", "engines": { "node": ">= 0.10" }, "main": "index.js", "files": [ "index.js" ], "scripts": { "lint": "eslint .", "pretest": "npm run lint", "test": "mocha --async-only", "cover": "istanbul cover _mocha --report lcovonly", "coveralls": "npm run cover && istanbul-coveralls" }, "dependencies": { "anymatch": "^2.0.0", "async-done": "^1.2.0", "chokidar": "^2.0.0", "is-negated-glob": "^1.0.0", "just-debounce": "^1.0.0", "normalize-path": "^3.0.0", "object.defaults": "^1.1.0" }, "devDependencies": { "coveralls": "^2.11.2", "eslint": "^2.13.1", "eslint-config-gulp": "^3.0.1", "expect": "^1.16.0", "istanbul": "^0.4.0", "istanbul-coveralls": "^1.0.1", "mocha": "^2.0.0", "mocha-lcov-reporter": "^1.2.0", "rimraf": "^2.6.1", "through2": "^2.0.1" }, "keywords": [ "watch", "glob", "async", "queue", "debounce", "callback" ] } node-gulp-4.0.2+~cs38.20.35/test/000077500000000000000000000000001415667007300160175ustar00rootroot00000000000000node-gulp-4.0.2+~cs38.20.35/test/.eslintrc000066400000000000000000000000351415667007300176410ustar00rootroot00000000000000{ "extends": "gulp/test" } node-gulp-4.0.2+~cs38.20.35/test/index.js000066400000000000000000000225031415667007300174660ustar00rootroot00000000000000'use strict'; var fs = require('fs'); var path = require('path'); var expect = require('expect'); var rimraf = require('rimraf'); var through = require('through2'); var normalizePath = require('normalize-path'); var watch = require('../'); // Default delay on debounce var timeout = 200; describe('glob-watcher', function() { var watcher; var outDir = path.join(__dirname, './fixtures/'); var outFile1 = path.join(outDir, 'changed.js'); var outFile2 = path.join(outDir, 'added.js'); var globPattern = '**/*.js'; var outGlob = normalizePath(path.join(outDir, globPattern)); var singleAdd = normalizePath(path.join(outDir, 'changed.js')); var ignoreGlob = '!' + singleAdd; function changeFile() { fs.writeFileSync(outFile1, 'hello changed'); } function addFile() { fs.writeFileSync(outFile2, 'hello added'); } beforeEach(function(cb) { fs.mkdirSync(outDir); fs.writeFileSync(outFile1, 'hello world'); cb(); }); afterEach(function(cb) { if (watcher) { watcher.close(); } rimraf(outDir, cb); }); after(function(cb) { rimraf(outDir, cb); }); it('only requires a glob and returns watcher', function(done) { watcher = watch(outGlob); watcher.once('change', function(filepath) { expect(filepath).toEqual(outFile1); done(); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', changeFile); }); it('picks up added files', function(done) { watcher = watch(outGlob); watcher.once('add', function(filepath) { expect(filepath).toEqual(outFile2); done(); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', addFile); }); it('works with OS-specific cwd', function(done) { watcher = watch('./fixtures/' + globPattern, { cwd: __dirname }); watcher.once('change', function(filepath) { // Uses path.join here because the resulting path is OS-specific expect(filepath).toEqual(path.join('fixtures', 'changed.js')); done(); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', changeFile); }); it('accepts a callback & calls when file is changed', function(done) { watcher = watch(outGlob, function(cb) { cb(); done(); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', changeFile); }); it('accepts a callback & calls when file is added', function(done) { watcher = watch(outGlob, function(cb) { cb(); done(); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', addFile); }); it('waits for completion is signaled before running again', function(done) { var runs = 0; watcher = watch(outGlob, function(cb) { runs++; if (runs === 1) { setTimeout(function() { expect(runs).toEqual(1); cb(); }, timeout * 3); } if (runs === 2) { cb(); done(); } }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', function() { changeFile(); // Fire after double the delay setTimeout(changeFile, timeout * 2); }); }); // It can signal completion with anything async-done supports // Just wanted to have a smoke test for streams it('can signal completion with a stream', function(done) { var runs = 0; watcher = watch(outGlob, function(cb) { runs++; if (runs === 1) { var stream = through(); setTimeout(function() { expect(runs).toEqual(1); stream.end(); }, timeout * 3); return stream; } if (runs === 2) { cb(); done(); } }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', function() { changeFile(); // Fire after double the delay setTimeout(changeFile, timeout * 2); }); }); it('emits an error if one occurs in the callback and handler attached', function(done) { var expectedError = new Error('boom'); watcher = watch(outGlob, function(cb) { cb(expectedError); }); watcher.on('error', function(err) { expect(err).toEqual(expectedError); done(); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', changeFile); }); it('does not emit an error (and crash) when no handlers attached', function(done) { var expectedError = new Error('boom'); watcher = watch(outGlob, function(cb) { cb(expectedError); setTimeout(done, timeout * 3); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', changeFile); }); it('allows the user to disable queueing', function(done) { var runs = 0; watcher = watch(outGlob, { queue: false }, function(cb) { runs++; setTimeout(function() { // Expect 1 because run 2 is never queued expect(runs).toEqual(1); cb(); done(); }, timeout * 3); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', function() { changeFile(); // This will never trigger a call because queueing is disabled setTimeout(changeFile, timeout * 2); }); }); it('allows the user to adjust delay', function(done) { var runs = 0; watcher = watch(outGlob, { delay: (timeout / 2) }, function(cb) { runs++; if (runs === 1) { setTimeout(function() { expect(runs).toEqual(1); cb(); }, timeout * 3); } if (runs === 2) { expect(runs).toEqual(2); cb(); done(); } }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', function() { changeFile(); // This will queue because delay is halved setTimeout(changeFile, timeout); }); }); it('passes options to chokidar', function(done) { // Callback is called while chokidar is discovering file paths // if ignoreInitial is explicitly set to false and passed to chokidar watcher = watch(outGlob, { ignoreInitial: false }, function(cb) { cb(); done(); }); }); it('does not override default values with null values', function(done) { watcher = watch(outGlob, { ignoreInitial: null }, function(cb) { cb(); done(); }); // We default `ignoreInitial` to true and it isn't overwritten by null // So wait for `on('ready')` watcher.on('ready', changeFile); }); it('watches exactly the given event', function(done) { var spy = expect.createSpy() .andCall(function(cb) { cb(); spy.andThrow(new Error('`Add` handler called for `change` event')); setTimeout(done, 500); changeFile(); }); watcher = watch(outGlob, { events: 'add' }, spy); watcher.on('ready', addFile); }); it('accepts multiple events to watch', function(done) { var spy = expect.createSpy() .andThrow(new Error('`Add`/`Unlink` handler called for `change` event')); watcher = watch(outGlob, { events: ['add', 'unlink'] }, spy); watcher.on('ready', function() { changeFile(); setTimeout(done, 500); }); }); it('can ignore a glob after it has been added', function(done) { watcher = watch([outGlob, ignoreGlob]); watcher.once('change', function(filepath) { // It should never reach here expect(filepath).toNotExist(); done(); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', changeFile); setTimeout(done, 1500); }); it('can re-add a glob after it has been negated', function(done) { watcher = watch([outGlob, ignoreGlob, singleAdd]); watcher.once('change', function(filepath) { expect(filepath).toEqual(singleAdd); done(); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', changeFile); }); it('does not mutate the globs array', function(done) { var globs = [outGlob, ignoreGlob, singleAdd]; watcher = watch(globs); expect(globs[0]).toEqual(outGlob); expect(globs[1]).toEqual(ignoreGlob); expect(globs[2]).toEqual(singleAdd); done(); }); it('passes ignores through to chokidar', function(done) { var ignored = [singleAdd]; watcher = watch(outGlob, { ignored: ignored, }); watcher.once('change', function(filepath) { // It should never reach here expect(filepath).toNotExist(); done(); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', changeFile); // Just test the non-mutation in this test expect(ignored.length).toEqual(1); setTimeout(done, 1500); }); // https://github.com/gulpjs/glob-watcher/issues/46 it('ignoring globs also works with `cwd` option', function(done) { watcher = watch(['fixtures/**', '!fixtures/*.js'], { cwd: 'test' }); watcher.once('change', function(filepath) { // It should never reach here expect(filepath).toNotExist(); done(); }); // We default `ignoreInitial` to true, so always wait for `on('ready')` watcher.on('ready', changeFile); setTimeout(done, 1500); }); });