From 74500d735d27ea514acca2eb3cca558c1d97fcef Mon Sep 17 00:00:00 2001 From: TeamworkGuy2 Date: Tue, 21 Jun 2016 22:28:32 +0000 Subject: [PATCH] Added watchify definition --- watchify/watchify-tests.ts | 33 ++++++++++++++++++++++++ watchify/watchify.d.ts | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 watchify/watchify-tests.ts create mode 100644 watchify/watchify.d.ts diff --git a/watchify/watchify-tests.ts b/watchify/watchify-tests.ts new file mode 100644 index 0000000000..278697ca2e --- /dev/null +++ b/watchify/watchify-tests.ts @@ -0,0 +1,33 @@ +/// + +import browserify = require("browserify"); +import watchify = require("watchify"); + +module WatchifyTest { + + export function setupWatchify(srcPath: string, opts?: watchify.Options) { + // new syntax + var bfyWatched = browserify(srcPath, { + cache: watchify.args.cache, + packageCache: watchify.args.packageCache, + plugin: [watchify], + }); + + var stream: NodeJS.ReadWriteStream; + bfyWatched.pipeline.get("deps").push(stream); + + // old syntax + var bfy = browserify(srcPath); + + var bfyWatched = watchify(bfy, { + delay: opts.delay || 100, + ignoreWatch: opts.ignoreWatch || false, + poll: opts.poll || 0, + }); + + bfy.pipeline.get('wrap').on("error", function () { }); + } + +} + +export = WatchifyTest; \ No newline at end of file diff --git a/watchify/watchify.d.ts b/watchify/watchify.d.ts new file mode 100644 index 0000000000..cad9cbf3af --- /dev/null +++ b/watchify/watchify.d.ts @@ -0,0 +1,51 @@ +// Type definitions for watchify v3.7.0 +// Project: https://github.com/substack/watchify +// Definitions by: TeamworkGuy2 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module 'watchify' { + + var Watchify: Watchify.Constructor; + + /** Watch mode for browserify builds. + * Update any source file and your browserify bundle will be recompiled on the spot + */ + module Watchify { + + /** Watch mode for browserify builds. + * Update any source file and your browserify bundle will be recompiled on the spot + */ + export interface Constructor { + args: { cache: any; packageCache: any; }; + + (b: T, opts?: Watchify.Options): T; + (b: Browserify.BrowserifyObject, opts?: Watchify.Options): Browserify.BrowserifyObject; + } + + + export interface Options { + /** The amount of time in milliseconds to wait before emitting an "update" event after a change. + * Default: 100 + */ + delay?: number; + + /** Ignores monitoring files for changes. If set to true, then ** /node_modules/ ** will be ignored. For other possible values see Chokidar's documentation on "ignored" + * Also see anymatch package: https://github.com/es128/anymatch#usage + */ + ignoreWatch?: boolean | (string | RegExp | ((...values: any[]) => boolean) | (string | RegExp | ((...values: any[]) => boolean))[]); + + /** Enables polling to monitor for changes. If set to true, then a polling interval of 100 ms is used. + * If set to a number, then that amount of milliseconds will be the polling interval. For more info see + * Chokidar's documentation on "usePolling" and "interval". + * This option is useful if you're watching an NFS volume + * Also see chokidar package: https://github.com/paulmillr/chokidar#path-filtering + */ + poll?: number; + } + + } + + export = Watchify; +}