diff options
Diffstat (limited to 'packages/iku/src/cli.ts')
| -rw-r--r-- | packages/iku/src/cli.ts | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/packages/iku/src/cli.ts b/packages/iku/src/cli.ts index c0a85fc..8ea07a4 100644 --- a/packages/iku/src/cli.ts +++ b/packages/iku/src/cli.ts @@ -2,7 +2,7 @@ import { existsSync } from "node:fs"; import { dirname, join } from "node:path"; -import { checkDirectory } from "./checker.js"; +import { checkDirectory, type CheckerOptions } from "./checker.js"; function findMonorepoRoot(startDirectory: string): string | null { let current = startDirectory; @@ -21,6 +21,23 @@ function findMonorepoRoot(startDirectory: string): string | null { return null; } +function parseArguments(arguments_: string[]): { directory?: string; options: CheckerOptions } { + const options: CheckerOptions = { + noComments: true, + }; + let directory: string | undefined; + + for (const argument of arguments_) { + if (argument === "--allow-comments") { + options.noComments = false; + } else if (!argument.startsWith("-")) { + directory = argument; + } + } + + return { directory, options }; +} + const monorepoRoot = findMonorepoRoot(process.cwd()); if (!monorepoRoot) { @@ -28,8 +45,9 @@ if (!monorepoRoot) { process.exit(1); } -const targetDirectory = process.argv[2] ?? join(monorepoRoot, "packages"); -const { errors, hasErrors } = checkDirectory(targetDirectory); +const { directory, options } = parseArguments(process.argv.slice(2)); +const targetDirectory = directory ?? join(monorepoRoot, "packages"); +const { errors, hasErrors } = checkDirectory(targetDirectory, options); for (const error of errors) { console.error(error); |