mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
51d22fa98d
plus more additional chars here PR Close #49200
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {spawn} from 'node:child_process';
|
|
import fs from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
|
|
/**
|
|
* Establishes the Saucelabs connect tunnel.
|
|
**/
|
|
export async function openSauceConnectTunnel(tunnelIdentifier: string, sauceConnect: string) {
|
|
console.debug('Starting sauce connect tunnel...');
|
|
|
|
const tmpFolder = await fs.mkdtemp('saucelabs-daemon-');
|
|
|
|
await new Promise<void>((resolve, reject) => {
|
|
// First we need to start the sauce connect tunnel
|
|
const sauceConnectArgs = [
|
|
'--readyfile',
|
|
`${tmpFolder}/readyfile`,
|
|
'--pidfile',
|
|
`${tmpFolder}/pidfile`,
|
|
'--tunnel-identifier',
|
|
tunnelIdentifier || path.basename(tmpFolder),
|
|
];
|
|
const sc = spawn(sauceConnect, sauceConnectArgs);
|
|
|
|
sc.stdout!.on('data', (data) => {
|
|
if (data.includes('Sauce Connect is up, you may start your tests.')) {
|
|
resolve();
|
|
}
|
|
});
|
|
|
|
sc.on('close', (code) => {
|
|
reject(new Error(`sauce connect closed all stdio with code ${code}`));
|
|
});
|
|
|
|
sc.on('exit', (code) => {
|
|
reject(new Error(`sauce connect exited with code ${code}`));
|
|
});
|
|
});
|
|
|
|
console.debug('Starting sauce connect tunnel established');
|
|
}
|