forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser-sync-tests.ts
122 lines (89 loc) · 2.37 KB
/
browser-sync-tests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/// <reference path="./browser-sync.d.ts"/>
import browserSync = require("browser-sync");
(() => {
//make sure that the interfaces are correctly exposed
var bsInstance: browserSync.BrowserSyncInstance;
var bsStatic: browserSync.BrowserSyncStatic;
var opts: browserSync.Options;
})();
browserSync({
server: {
baseDir: "./"
}
});
// multiple base directory
browserSync({
server: {
baseDir: ["app", "dist"]
}
});
browserSync({
proxy: "yourlocal.dev"
});
var config = {
server: {
baseDir: "./"
}
};
// config only
browserSync(config);
// config + callback
browserSync(config, function (err, bs) {
if (!err) {
console.log("BrowserSync is ready!");
}
});
// browser reload
browserSync.reload();
// single file
browserSync.reload( "styles.css" );
// multiple files
browserSync.reload( ["styles.css", "ie.css"] );
// streams support
browserSync.reload( { stream: true } );
browserSync.notify("Compiling, please wait!");
browserSync.notify("HTML <span color='green'>is supported</span> too!");
// Since 1.3.0, specify a timeout
browserSync.notify("This message will only last a second", 1000);
browserSync(config, function (err, bs) {
browserSync.exit();
});
console.log(browserSync.active); // false
browserSync(config, function (err, bs) {
console.log(browserSync.active); // true
});
var evt = browserSync.emitter;
evt.on("init", function () {
console.log("BrowserSync is running!");
});
browserSync(config);
var has = browserSync.has("My server");
var bs = browserSync.create();
bs.init({
server: "./app"
});
bs.reload();
function browserSyncInit(): browserSync.BrowserSyncInstance {
var browser = browserSync.create();
browser.init();
console.log(browser.name);
console.log(browserSync.name);
return browser;
}
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]});