Skip to content

Commit

Permalink
Merge branch 'denoland:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tlgimenes authored Oct 5, 2023
2 parents 5ccebd2 + 77ed100 commit aedc5b1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/dev/dev_command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function dev(
} else {
currentManifest = { islands: [], routes: [] };
}
const newManifest = await collect(dir, options);
const newManifest = await collect(dir, options?.router?.ignoreFilePattern);
Deno.env.set("FRSH_DEV_PREVIOUS_MANIFEST", JSON.stringify(newManifest));

const manifestChanged =
Expand Down
11 changes: 5 additions & 6 deletions src/dev/mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { gte, join, posix, relative, walk, WalkEntry } from "./deps.ts";
import { error } from "./error.ts";
import { FreshOptions } from "../server/mod.ts";
const MIN_DENO_VERSION = "1.31.0";
const TEST_FILE_PATTERN = /[._]test\.(?:[tj]sx?|[mc][tj]s)$/;

Expand All @@ -24,7 +23,7 @@ export function ensureMinDenoVersion() {
async function collectDir(
dir: string,
callback: (entry: WalkEntry, dir: string) => void,
options: FreshOptions,
ignoreFilePattern = TEST_FILE_PATTERN,
): Promise<void> {
// Check if provided path is a directory
try {
Expand All @@ -39,7 +38,7 @@ async function collectDir(
includeDirs: false,
includeFiles: true,
exts: ["tsx", "jsx", "ts", "js"],
skip: [options?.router?.ignoreFilePattern || TEST_FILE_PATTERN],
skip: [ignoreFilePattern],
});

for await (const entry of routesFolder) {
Expand All @@ -55,7 +54,7 @@ export interface Manifest {
const GROUP_REG = /[/\\\\]\((_[^/\\\\]+)\)[/\\\\]/;
export async function collect(
directory: string,
options: FreshOptions = {},
ignoreFilePattern?: RegExp,
): Promise<Manifest> {
const filePaths = new Set<string>();

Expand Down Expand Up @@ -84,11 +83,11 @@ export async function collect(
}
filePaths.add(normalized);
routes.push(rel);
}, options),
}, ignoreFilePattern),
collectDir(join(directory, "./islands"), (entry, dir) => {
const rel = join("islands", relative(dir, entry.path));
islands.push(rel);
}, options),
}, ignoreFilePattern),
]);

routes.sort();
Expand Down
6 changes: 3 additions & 3 deletions src/server/mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { LayoutConfig } from "$fresh/server.ts";
import { ComponentChildren } from "preact";
import { ServerContext } from "./context.ts";
export type { FromManifestOptions } from "./context.ts";
export { Status } from "./deps.ts";
Expand All @@ -8,6 +6,7 @@ import {
Handler,
Handlers,
IslandModule,
LayoutConfig,
MiddlewareModule,
RouteConfig,
ServeHandlerInfo,
Expand Down Expand Up @@ -72,7 +71,8 @@ export interface Manifest {
propsOrRequest: any,
// deno-lint-ignore no-explicit-any
ctx: any,
) => Promise<ComponentChildren | Response> | ComponentChildren;
// deno-lint-ignore no-explicit-any
) => Promise<any | Response> | any;
// deno-lint-ignore no-explicit-any
handler?: Handler<any, any> | Handlers<any, any> | UnknownHandler;
config?: RouteConfig | LayoutConfig | ErrorHandler;
Expand Down
7 changes: 1 addition & 6 deletions tests/dev_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Deno.test({
fn: async () => {
const { routes } = await collect(
join(dirname(fromFileUrl(import.meta.url)), "fixture"),
{},
);

assert(
Expand All @@ -32,11 +31,7 @@ Deno.test({
dirname(fromFileUrl(import.meta.url)),
"fixture_router_ignore_files",
),
{
router: {
ignoreFilePattern: /[\.|_]cy\.[t|j]s(x)?$/,
},
},
/[\.|_]cy\.[t|j]s(x)?$/,
);

assert(
Expand Down

0 comments on commit aedc5b1

Please sign in to comment.