chore: allow specifying output dir (#285)
Ref: https://github.com/microsoft/playwright-mcp/issues/279
This commit is contained in:
parent
6e76d5e550
commit
697a69a8c2
6 changed files with 52 additions and 11 deletions
|
|
@ -14,8 +14,12 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import net from 'net';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
|
||||
import { sanitizeForFilePath } from './tools/utils';
|
||||
|
||||
import type { Config } from '../config';
|
||||
import type { LaunchOptions, BrowserContextOptions } from 'playwright';
|
||||
|
|
@ -84,3 +88,10 @@ async function findFreePort() {
|
|||
server.on('error', reject);
|
||||
});
|
||||
}
|
||||
|
||||
export async function outputFile(config: Config, name: string): Promise<string> {
|
||||
const result = config.outputDir ?? os.tmpdir();
|
||||
await fs.promises.mkdir(result, { recursive: true });
|
||||
const fileName = sanitizeForFilePath(name);
|
||||
return path.join(result, fileName);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue