Skip to content

Commit

Permalink
Rename WorkersProjectOptions to WorkersPoolOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbbot committed Feb 14, 2024
1 parent 07c6035 commit 49b9299
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/vitest-pool-workers/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert";
import { MessageChannel, receiveMessageOnPort } from "node:worker_threads";
import type { WorkersProjectOptions } from "../pool/config";
import type { WorkersPoolOptions } from "../pool/config";
import type { Awaitable, inject } from "vitest";

// Vitest will call `structuredClone()` to verify data is serialisable.
Expand All @@ -26,8 +26,8 @@ export interface WorkerPoolOptionsContext {

export function defineWorkersPoolOptions(
options:
| WorkersProjectOptions
| ((ctx: WorkerPoolOptionsContext) => Awaitable<WorkersProjectOptions>)
| WorkersPoolOptions
| ((ctx: WorkerPoolOptionsContext) => Awaitable<WorkersPoolOptions>)
) {
return options;
}
8 changes: 4 additions & 4 deletions packages/vitest-pool-workers/src/pool/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export type SourcelessWorkerOptions = Omit<
WorkerOptions,
"script" | "scriptPath" | "modules" | "modulesRoot" | "modulesRule"
>;
export type WorkersProjectOptions = z.input<typeof WorkersPoolOptionsSchema> & {
export type WorkersPoolOptions = z.input<typeof WorkersPoolOptionsSchema> & {
miniflare?: SourcelessWorkerOptions & {
workers?: WorkerOptions[];
};
Expand Down Expand Up @@ -114,7 +114,7 @@ function parseCustomPoolOptions(
rootPath: string,
value: unknown,
opts: PathParseParams
): WorkersProjectOptions {
): WorkersPoolOptions {
// Try to parse pool specific options
const options = WorkersPoolOptionsSchema.parse(value, opts);
options.miniflare ??= {};
Expand Down Expand Up @@ -158,12 +158,12 @@ function parseCustomPoolOptions(

if (errorRef.value !== undefined) throw errorRef.value;

return options as WorkersProjectOptions;
return options as WorkersPoolOptions;
}

export async function parseProjectOptions(
project: WorkspaceProject
): Promise<WorkersProjectOptions> {
): Promise<WorkersPoolOptions> {
// Make sure the user hasn't specified a custom environment. This was how
// users enabled Miniflare 2's Vitest environment, so it's likely users will
// hit this case.
Expand Down
6 changes: 3 additions & 3 deletions packages/vitest-pool-workers/src/pool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
ensurePosixLikePath,
handleModuleFallbackRequest,
} from "./module-fallback";
import type { WorkersProjectOptions, SourcelessWorkerOptions } from "./config";
import type { WorkersPoolOptions, SourcelessWorkerOptions } from "./config";
import type { CloseEvent, MiniflareOptions, WorkerOptions } from "miniflare";
import type { MessagePort } from "node:worker_threads";
import type { Readable } from "node:stream";
Expand Down Expand Up @@ -112,7 +112,7 @@ function forEachMiniflare(

interface Project {
project: WorkspaceProject;
options: WorkersProjectOptions;
options: WorkersPoolOptions;
testFiles: Set<string>;
relativePath: string | number;
mf?: SingleOrPerTestFileMiniflare;
Expand Down Expand Up @@ -155,7 +155,7 @@ interface DurableObjectDesignator {
* the objects they point to.
*/
function getDurableObjectDesignators(
options: WorkersProjectOptions
options: WorkersPoolOptions
): Map<string /* bound name */, DurableObjectDesignator> {
const result = new Map<string, DurableObjectDesignator>();
const durableObjects = options.miniflare?.durableObjects ?? {};
Expand Down

0 comments on commit 49b9299

Please sign in to comment.