Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanniser committed Dec 7, 2024
1 parent 6daa700 commit d2e9d9e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
1 change: 0 additions & 1 deletion examples/custom-filename/_next-typesafe-url_.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// prettier-ignore
/* eslint-disable */


declare module "@@@next-typesafe-url" {
import type { InferRoute, StaticRoute } from "next-typesafe-url";

Expand Down
20 changes: 10 additions & 10 deletions packages/next-typesafe-url/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const cli = meow(helpText, {
filename: {
type: "string",
default: "routeType",
}
},
},
});

Expand All @@ -62,7 +62,7 @@ export type RouteInformation = {
function build({
paths,
pageExtensions,
filename
filename,
}: {
paths: Paths;
pageExtensions: string[];
Expand Down Expand Up @@ -91,15 +91,15 @@ function build({
appRoutesInfo,
pagesRoutesInfo,
paths,
filename
filename,
});
console.log(`Generated route types`);
}

function watch({
paths,
pageExtensions,
filename
filename,
}: {
paths: Paths;
pageExtensions: string[];
Expand All @@ -111,7 +111,7 @@ function watch({
chokidar
.watch([`${absoluteAppPath}/**/*.{${pageExtensions.join(",")}}`])
.on("change", () => {
build({filename, paths, pageExtensions });
build({ filename, paths, pageExtensions });
});
}
if (absolutePagesPath) {
Expand All @@ -126,7 +126,7 @@ function watch({
}

if (require.main === module) {
const {filename, srcPath, outputPath } = cli.flags;
const { filename, srcPath, outputPath } = cli.flags;
const pageExtensions = cli.flags.pageExtensions.split(",");

const absoluteSrcPath = path.join(process.cwd(), srcPath);
Expand All @@ -139,7 +139,7 @@ if (require.main === module) {
const absoluteOutputPath = path.join(process.cwd(), outputPath);
const relativePathFromOutputToSrc = path.relative(
path.dirname(absoluteOutputPath),
absoluteSrcPath
absoluteSrcPath,
);

const appPath = path.join(absoluteSrcPath, "app");
Expand All @@ -156,10 +156,10 @@ if (require.main === module) {
};

if (cli.flags.watch) {
build({filename, paths, pageExtensions });
watch({filename, paths, pageExtensions });
build({ filename, paths, pageExtensions });
watch({ filename, paths, pageExtensions });
} else {
build({filename, paths, pageExtensions });
build({ filename, paths, pageExtensions });
}
}

Expand Down
10 changes: 5 additions & 5 deletions packages/next-typesafe-url/src/generateTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function getPAGESRoutesWithExportedRoute({
hasRoute,
doesntHaveRoute,
pageExtensions,
filename
filename,
});
} else {
const fileName = path.basename(fullPath);
Expand All @@ -41,7 +41,7 @@ export function getPAGESRoutesWithExportedRoute({

const fileContent = fs.readFileSync(fullPath, "utf8");
const hasExportedRouteType = /export\s+type\s+RouteType\b/.test(
fileContent
fileContent,
);

let routePath = fullPath
Expand Down Expand Up @@ -79,7 +79,7 @@ export function getAPPRoutesWithExportedRoute({
hasRoute = [],
doesntHaveRoute = [],
pageExtensions,
filename
filename,
}: {
basePath: string;
dir: string;
Expand Down Expand Up @@ -112,7 +112,7 @@ export function getAPPRoutesWithExportedRoute({
hasRoute,
doesntHaveRoute,
pageExtensions,
filename
filename,
});
} else if (
// Matches page files with the extensions from pageExtensions
Expand All @@ -129,7 +129,7 @@ export function getAPPRoutesWithExportedRoute({
}

const routeTypePaths = ["ts", "tsx"].map((ext) =>
path.join(dir, `${filename}.${ext}`)
path.join(dir, `${filename}.${ext}`),
);
const didAddRoute = routeTypePaths.reduce((didAdd, routeTypePath) => {
// Avoid adding the same route twice
Expand Down

0 comments on commit d2e9d9e

Please sign in to comment.