Skip to content

Commit

Permalink
update verbose mode detection
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaaas committed Sep 8, 2021
1 parent b1ce9d0 commit 3dc6fd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/createRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from "path"
import type { IOptions } from "./types"

import config from "./config"
import { defaultOptions, REQUIRE_MAIN_FILE } from "./options"
import { defaultOptions, REQUIRE_MAIN_FILE, verboseTypes } from "./options"
import { walk, generateRoutes, getHandlers, getMethodKey, log } from "./utils"

/**
Expand All @@ -26,6 +26,9 @@ const createRouter = <T>(app: T, opts: IOptions = defaultOptions): T => {

if (!opts.base) opts.base = opts.directory.replace(REQUIRE_MAIN_FILE, "")
}

if (opts.verbose === "dev") opts.verbose = verboseTypes["dev"]

const options = { ...defaultOptions, ...opts }

const files = walk(options.directory)
Expand Down
4 changes: 1 addition & 3 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import type { IOptions } from "./types"
export const REQUIRE_MAIN_FILE = path.dirname(require.main.filename)

export const verboseTypes = {
false: false,
dev: process.env.NODE_ENV !== "production",
true: true
dev: process.env.NODE_ENV !== "production"
}

export const defaultOptions: IOptions = {
Expand Down

0 comments on commit 3dc6fd3

Please sign in to comment.