Skip to content

Commit c167f57

Browse files
author
Kartik Raj
committed
Add documentation of python binary watcher
1 parent 06e6f5b commit c167f57

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/client/pythonEnvironments/common/pythonBinariesWatcher.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@ import { getOSType, OSType } from '../../common/utils/platform';
1111

1212
const [executable, binName] = getOSType() === OSType.Windows ? ['python.exe', 'Scripts'] : ['python', 'bin'];
1313

14+
/**
15+
* @param baseDir The base directory from which watch paths are to be derived.
16+
* @param callback The listener function will be called when the event happens.
17+
* @param executableSuffixGlob Glob which represents suffix of the full executable file path to watch.
18+
*/
1419
export function watchLocationForPythonBinaries(
1520
baseDir: string,
1621
callback: (type: FileChangeType, absPath: string) => void,
17-
executableGlob: string = executable,
22+
executableSuffixGlob: string = executable,
1823
): Disposable {
19-
const patterns = [executableGlob, `*/${executableGlob}`, `*/${binName}/${executableGlob}`];
24+
const patterns = [executableSuffixGlob, `*/${executableSuffixGlob}`, `*/${binName}/${executableSuffixGlob}`];
2025
const disposables: Disposable[] = [];
2126
for (const pattern of patterns) {
2227
disposables.push(watchLocationForPattern(baseDir, pattern, (type: FileChangeType, e: string) => {
23-
const isMatch = minimatch(e, path.join('**', executableGlob), { nocase: getOSType() === OSType.Windows });
28+
const isMatch = minimatch(e, path.join('**', executableSuffixGlob), { nocase: getOSType() === OSType.Windows });
2429
if (!isMatch) {
2530
// When deleting the file for some reason path to all directories leading up to python are reported
2631
// Skip those events

0 commit comments

Comments
 (0)