blob: c84cf155cd25ebe54a860c74b15baa1bbc38ca70 (
plain)
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
|
import browserstackLocal from "browserstack-local";
export async function localTunnel( localIdentifier, opts = {} ) {
const tunnel = new browserstackLocal.Local();
return new Promise( ( resolve, reject ) => {
// https://www.browserstack.com/docs/local-testing/binary-params
tunnel.start(
{
"enable-logging-for-api": "",
localIdentifier,
...opts
},
async( error ) => {
if ( error || !tunnel.isRunning() ) {
return reject( error );
}
resolve( {
stop: function stopTunnel() {
return new Promise( ( resolve, reject ) => {
tunnel.stop( ( error ) => {
if ( error ) {
return reject( error );
}
resolve();
} );
} );
}
} );
}
);
} );
}
|