File tree Expand file tree Collapse file tree 4 files changed +11
-29
lines changed Expand file tree Collapse file tree 4 files changed +11
-29
lines changed Original file line number Diff line number Diff line change 115
115
},
116
116
"phpstan.configPath" : {
117
117
"type" : " string" ,
118
- "description" : " PHPStan config path"
118
+ "description" : " PHPStan config path" ,
119
+ "default" : " {phpstan.neon,phpstan.neon.dist}"
119
120
},
120
121
"phpstan.analysedDelay" : {
121
122
"type" : " integer" ,
Original file line number Diff line number Diff line change 1
1
import { Ext } from "../extension" ;
2
- import { findPHPStanConfigPath as find } from "../utils/phpstan" ;
3
- import { isAbsolute , join } from "path" ;
2
+ import { RelativePattern , workspace } from "vscode" ;
4
3
5
4
export default async function findPHPStanConfigPath ( ext : Ext ) {
6
5
const { settings, cwd } = ext ;
7
- const configPath = settings . configPath
8
- ? isAbsolute ( settings . configPath )
9
- ? settings . configPath
10
- : join ( cwd , settings . configPath )
11
- : await find ( ext . cwd ) ;
12
-
13
- if ( ! configPath ) throw new Error ( `Config path not found.` ) ;
6
+ const [ configUri ] = await workspace . findFiles (
7
+ new RelativePattern ( cwd , settings . configPath ) ,
8
+ null ,
9
+ 1
10
+ ) ;
11
+ if ( ! configUri ) throw new Error ( `Config path not found.` ) ;
12
+ const configPath = configUri . fsPath ;
14
13
ext . log ( { tag : "configPath" , message : configPath } ) ;
15
14
return configPath ;
16
15
}
Original file line number Diff line number Diff line change @@ -199,11 +199,7 @@ export class Ext<
199
199
200
200
if ( this . settings . configFileWatcher )
201
201
this . fileWatchers . register (
202
- this . settings . configPath ??
203
- new RelativePattern (
204
- getWorkspacePath ( ) ,
205
- `{phpstan.neon,phpstan.neon.dist}`
206
- ) ,
202
+ new RelativePattern ( getWorkspacePath ( ) , this . settings . configPath ) ,
207
203
( uri , eventName ) => {
208
204
if ( ! this . store . fileWatcher . enabled ) return ;
209
205
const path = sanitizeFsPath ( uri . fsPath ) ;
Original file line number Diff line number Diff line change 1
- import { checkFile } from "./fs" ;
2
1
import { parseNeonFile } from "./neon" ;
3
2
import { resolvePath } from "./path" ;
4
- import { join } from "path" ;
5
3
6
4
export type PHPStanAnalyseResult = {
7
5
totals : {
@@ -49,18 +47,6 @@ export async function parsePHPStanConfigFile(
49
47
return normalizePHPStanConfig ( config , env . currentWorkingDirectory ) ;
50
48
}
51
49
52
- export async function findPHPStanConfigPath (
53
- cwd : string
54
- ) : Promise < string | undefined > {
55
- const baseNames = [ "phpstan.neon" , "phpstan.neon.dist" ] ;
56
- for ( const basename of baseNames ) {
57
- const path = join ( cwd , basename ) ;
58
- if ( await checkFile ( path ) ) {
59
- return path ;
60
- }
61
- }
62
- }
63
-
64
50
export function normalizePHPStanConfig (
65
51
config : PHPStanConfig ,
66
52
cwd : string
You can’t perform that action at this time.
0 commit comments