Fixes PATH handling for Windows compatibility
Ensures that the PATH environment variable is correctly augmented with
additional paths, especially on Windows systems. It uses platform-specific
path delimiters (';' on Windows, ':' on Unix) and filters out empty segments
to prevent PATH corruption.
This commit is contained in:
1 file changed
+13
-2
@@ -73,8 +73,11 @@ export class ExecutableChecker {
|
|||||||
* The resulting PATH helps find executables in non-standard locations that
|
* The resulting PATH helps find executables in non-standard locations that
|
||||||
* might not be in the user's shell PATH when running from Obsidian.
|
* might not be in the user's shell PATH when running from Obsidian.
|
||||||
*
|
*
|
||||||
|
* Uses platform-specific path delimiters (';' on Windows, ':' on Unix) and
|
||||||
|
* filters out empty segments to prevent PATH corruption.
|
||||||
|
*
|
||||||
* @param additionalPaths - Optional array of additional paths to include
|
* @param additionalPaths - Optional array of additional paths to include
|
||||||
* @returns The augmented PATH string with all paths separated by colons
|
* @returns The augmented PATH string with all paths separated by platform-specific delimiter
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private static getAugmentedPath(additionalPaths: string[] = []): string {
|
private static getAugmentedPath(additionalPaths: string[] = []): string {
|
||||||
@@ -88,7 +91,15 @@ export class ExecutableChecker {
|
|||||||
// Combine default system paths with user-provided additional paths
|
// Combine default system paths with user-provided additional paths
|
||||||
const allAdditionalPaths = [...defaultSystemPaths, ...additionalPaths];
|
const allAdditionalPaths = [...defaultSystemPaths, ...additionalPaths];
|
||||||
|
|
||||||
return `${process.env.PATH}:${allAdditionalPaths.join(':')}`;
|
// Use platform-specific delimiter (';' on Windows, ':' on Unix)
|
||||||
|
const delimiter = process.platform === 'win32' ? ';' : ':';
|
||||||
|
|
||||||
|
// Filter out empty segments and join with platform-specific delimiter
|
||||||
|
const segments = [
|
||||||
|
process.env.PATH ?? '',
|
||||||
|
...allAdditionalPaths.filter(p => p && p.trim() !== '')
|
||||||
|
];
|
||||||
|
return segments.filter(Boolean).join(delimiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user