Skip to content

Commit

Permalink
Makes astro check --tsconfig understand relative file names (#804)
Browse files Browse the repository at this point in the history
* Makes astro check --tsconfig understand relative file names

* a little more compact
  • Loading branch information
martrapp committed Feb 23, 2024
1 parent 28ecc47 commit fe6165b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/chilled-adults-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@astrojs/language-server": patch
"@astrojs/check": patch
---

Makes astro check --tsconfig understand relative file names
10 changes: 6 additions & 4 deletions packages/language-server/src/check.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { existsSync } from 'node:fs';
import { homedir } from 'node:os';
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import * as kit from '@volar/kit';
import { Diagnostic, DiagnosticSeverity } from '@volar/language-server';
Expand Down Expand Up @@ -157,11 +159,11 @@ export class AstroCheck {

private getTsconfig() {
if (this.tsconfigPath) {
if (!existsSync(this.tsconfigPath)) {
throw new Error(`Specified tsconfig file \`${this.tsconfigPath}\` does not exist.`);
const tsconfig = resolve(this.workspacePath, this.tsconfigPath.replace(/^~/, homedir()));
if (!existsSync(tsconfig)) {
throw new Error(`Specified tsconfig file \`${tsconfig}\` does not exist.`);
}

return this.tsconfigPath;
return tsconfig;
}

const searchPath = this.workspacePath;
Expand Down

0 comments on commit fe6165b

Please sign in to comment.