From ce56f8e2f4a2a169cb84d3a7af30b5c1528f67b2 Mon Sep 17 00:00:00 2001 From: Glen Date: Sun, 29 Nov 2015 15:12:26 +0200 Subject: [PATCH] Update stream() signature and add tests --- browser-sync/browser-sync-tests.ts | 23 +++++++++++++++++++++++ browser-sync/browser-sync.d.ts | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/browser-sync/browser-sync-tests.ts b/browser-sync/browser-sync-tests.ts index 210a8cf1b..e54439afb 100644 --- a/browser-sync/browser-sync-tests.ts +++ b/browser-sync/browser-sync-tests.ts @@ -95,3 +95,26 @@ function browserSyncInit(): browserSync.BrowserSyncInstance { } var browser = browserSyncInit(); browser.exit(); + +// Stream method. + +// -- No options. +browser.stream(); + +// -- "once" option. +browser.stream({once: true}); + +// -- "match" option (string). +browser.stream({match: "**/*.js"}); + +// -- "match" option (RegExp). +browser.stream({match: /\.js$/}); + +// -- "match" option (function). +browser.stream({match: (testString) => true}); + +// -- "match" option (array). +browser.stream({match: ["**/*.js", /\.js$/, (testString) => true]}); + +// -- Both options. +browser.stream({once: true, match: ["**/*.js", /\.js$/, (testString) => true]}); diff --git a/browser-sync/browser-sync.d.ts b/browser-sync/browser-sync.d.ts index 9d4cbcce3..05dcaaaa3 100644 --- a/browser-sync/browser-sync.d.ts +++ b/browser-sync/browser-sync.d.ts @@ -365,7 +365,7 @@ declare module "browser-sync" { * The stream method returns a transform stream and can act once or on many files. * @param opts Configuration for the stream method */ - stream(opts?: { once: boolean }): NodeJS.ReadWriteStream; + stream(opts?: { once?: boolean, match?: string | RegExp | ((testString: string) => boolean) | (string | RegExp | ((testString: string) => boolean))[] }): NodeJS.ReadWriteStream; /** * Helper method for browser notifications * @param message Can be a simple message such as 'Connected' or HTML