Skip to content

Commit

Permalink
breaking: throw when --ignore is used without --no-tsconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
dummdidumm committed Aug 20, 2024
1 parent 7a1f80a commit f580633
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/svelte-check/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,18 @@ export function parseOptions(cb: (opts: SvelteCheckCliOptions) => any) {
)
.action((opts) => {
const workspaceUri = getWorkspaceUri(opts);
const tsconfig = getTsconfig(opts, workspaceUri.fsPath);

if (opts.ignore && tsconfig) {
throwError('`--ignore` only has an effect when using `--no-tsconfig`');
}

cb({
workspaceUri,
outputFormat: getOutputFormat(opts),
watch: !!opts.watch,
preserveWatchOutput: !!opts.preserveWatchOutput,
tsconfig: getTsconfig(opts, workspaceUri.fsPath),
tsconfig,
filePathsToIgnore: opts.ignore?.split(',') || [],
failOnWarnings: !!opts['fail-on-warnings'],
compilerWarnings: getCompilerWarnings(opts),
Expand Down Expand Up @@ -141,11 +147,15 @@ function getTsconfig(myArgs: Record<string, any>, workspacePath: string) {
tsconfig = path.join(workspacePath, tsconfig);
}
if (tsconfig && !fs.existsSync(tsconfig)) {
throw new Error('Could not find tsconfig/jsconfig file at ' + myArgs.tsconfig);
throwError('Could not find tsconfig/jsconfig file at ' + myArgs.tsconfig);
}
return tsconfig;
}

function throwError(msg: string) {
throw new Error('Invalid svelte-check CLI args: ' + msg);
}

function getCompilerWarnings(opts: Record<string, any>) {
return stringToObj(opts['compiler-warnings']);

Expand Down

0 comments on commit f580633

Please sign in to comment.