-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow relative patterns in
configPath
- Loading branch information
Showing
4 changed files
with
11 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
import { Ext } from "../extension"; | ||
import { findPHPStanConfigPath as find } from "../utils/phpstan"; | ||
import { isAbsolute, join } from "path"; | ||
import { RelativePattern, workspace } from "vscode"; | ||
|
||
export default async function findPHPStanConfigPath(ext: Ext) { | ||
const { settings, cwd } = ext; | ||
const configPath = settings.configPath | ||
? isAbsolute(settings.configPath) | ||
? settings.configPath | ||
: join(cwd, settings.configPath) | ||
: await find(ext.cwd); | ||
|
||
if (!configPath) throw new Error(`Config path not found.`); | ||
const [configUri] = await workspace.findFiles( | ||
new RelativePattern(cwd, settings.configPath), | ||
null, | ||
1 | ||
); | ||
if (!configUri) throw new Error(`Config path not found.`); | ||
const configPath = configUri.fsPath; | ||
ext.log({ tag: "configPath", message: configPath }); | ||
return configPath; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters