mirror of
https://github.com/lancedb/lancedb.git
synced 2025-12-26 06:39:57 +00:00
This is done as setup for a PR that will fix the OpenAI dependency issue. * [x] FTS examples * [x] Setup mock openai * [x] Ran `npm audit fix` * [x] sentences embeddings test * [x] Double check formatting of docs examples
17 lines
442 B
TypeScript
17 lines
442 B
TypeScript
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
import * as fs from "fs";
|
|
import { tmpdir } from "os";
|
|
import * as path from "path";
|
|
|
|
export async function withTempDirectory(
|
|
fn: (tempDir: string) => Promise<void>,
|
|
) {
|
|
const tmpDirPath = fs.mkdtempSync(path.join(tmpdir(), "temp-dir-"));
|
|
try {
|
|
await fn(tmpDirPath);
|
|
} finally {
|
|
fs.rmSync(tmpDirPath, { recursive: true });
|
|
}
|
|
}
|