Skip to content

Commit

Permalink
Set tmpdir default
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderRonde committed Jun 28, 2024
1 parent 6f1cccc commit 819d35c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@
},
"phpstan.tmpDir": {
"type": "string",
"description": "Path to the PHPStan TMP directory. Defaults to PHPStan's default (which is /tmp/phpstan)"
"description": "Path to the PHPStan TMP directory. Defaults to PHPStan's default (which is /tmp/phpstan)",
"default": "/tmp/phpstan"
},
"phpstan.checkValidity": {
"type": "boolean",
Expand Down
10 changes: 6 additions & 4 deletions server/src/lib/editorConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ConfigSettingsWithoutPrefix } from '../../../shared/config';
import type { ClassConfig, WorkspaceFolders } from './types';
import { DEFAULT_TMP_DIR } from '../../../shared/constants';
import type { Disposable } from 'vscode-languageserver';
import { fromEntries } from '../../../shared/util';

Expand All @@ -15,6 +16,10 @@ export async function getEditorConfiguration(
section: 'phpstan',
})) as ConfigSettingsWithoutPrefix;

let tmpDir = editorConfig.tmpDir;
if (tmpDir === DEFAULT_TMP_DIR) {
tmpDir = editorConfig.proTmpDir || editorConfig.tmpDir;
}
return {
...editorConfig,
binPath: replaceVariables(editorConfig.binPath, workspaceFolders),
Expand All @@ -28,10 +33,7 @@ export async function getEditorConfiguration(
replaceVariables(value, workspaceFolders),
])
),
tmpDir: replaceVariables(
editorConfig.tmpDir || editorConfig.proTmpDir || '',
workspaceFolders
),
tmpDir: replaceVariables(tmpDir, workspaceFolders),
rootDir: replaceVariables(editorConfig.rootDir, workspaceFolders),
options: editorConfig.options.map((option) =>
replaceVariables(option, workspaceFolders)
Expand Down
2 changes: 2 additions & 0 deletions shared/commands/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {
ViewDefinition,
ConfigurationDefinition,
} from 'vscode-generate-package-json';
import { DEFAULT_TMP_DIR } from '../constants';

export enum Commands {
SCAN_FILE_FOR_ERRORS = 'phpstan.scanFileForErrors',
Expand Down Expand Up @@ -204,6 +205,7 @@ export const config = {
type: 'string',
description:
"Path to the PHPStan TMP directory. Defaults to PHPStan's default (which is /tmp/phpstan)",
default: DEFAULT_TMP_DIR,
},
},
'phpstan.checkValidity': {
Expand Down
1 change: 1 addition & 0 deletions shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export const SPAWN_ARGS = {
shell: process.platform === 'win32',
windowsVerbatimArguments: true,
};
export const DEFAULT_TMP_DIR = '/tmp/phpstan';

0 comments on commit 819d35c

Please sign in to comment.