vscode#FileSystemWatcher TypeScript Examples
The following examples show how to use
vscode#FileSystemWatcher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: dbtWorkspaceFolder.ts From vscode-dbt-power-user with MIT License | 6 votes |
private createConfigWatcher(): FileSystemWatcher {
const watcher = workspace.createFileSystemWatcher(
new RelativePattern(
this.workspaceFolder,
`**/${DBTProject.DBT_PROJECT_FILE}`
)
);
const dirName = (uri: Uri) => Uri.file(path.dirname(uri.fsPath));
watcher.onDidCreate((uri) => {
if (this.notInVenv(uri.fsPath)) {
this.registerDBTProject(dirName(uri));
}
});
watcher.onDidDelete((uri) => this.unregisterDBTProject(dirName(uri)));
this.disposables.push(watcher);
return watcher;
}
Example #2
Source File: targetWatchers.ts From vscode-dbt-power-user with MIT License | 6 votes |
private createManifestWatcher(
event: ProjectConfigChangedEvent
): FileSystemWatcher {
const { targetPath, projectRoot } = event;
const manifestWatcher = workspace.createFileSystemWatcher(
new RelativePattern(
projectRoot.path,
`${targetPath}/${DBTProject.MANIFEST_FILE}`
)
);
return manifestWatcher;
}
Example #3
Source File: targetWatchers.ts From vscode-dbt-power-user with MIT License | 6 votes |
private createTargetFolderWatcher(
event: ProjectConfigChangedEvent
): FileSystemWatcher {
const { targetPath, projectRoot } = event;
const targetFolderWatcher = workspace.createFileSystemWatcher(
new RelativePattern(projectRoot.path, targetPath)
);
return targetFolderWatcher;
}
Example #4
Source File: utils.ts From vscode-dbt-power-user with MIT License | 6 votes |
setupWatcherHandler: (
watcher: FileSystemWatcher,
handler: Function
) => Disposable[] = (watcher, handler) => [
watcher.onDidChange(() => handler()),
watcher.onDidCreate(() => handler()),
watcher.onDidDelete(() => handler()),
]
Example #5
Source File: file-watcher.ts From karma-test-explorer with MIT License | 6 votes |
private registerFileHandler(
filePatterns: readonly string[],
handler: (filePath: string, changeType: FileChangeType) => void
): FileSystemWatcher[] {
const fileWatchers: FileSystemWatcher[] = [];
const workspaceRootPath = normalizePath(this.workspaceFolder.uri.fsPath);
const relativeProjectRootPath = relative(workspaceRootPath, this.projectRootPath);
const isProjectRootSameAsWorkspace = this.projectRootPath === workspaceRootPath;
this.logger.debug(() => `Registering file handler for files: ${JSON.stringify(filePatterns, null, 2)}`);
for (const fileOrPattern of filePatterns) {
const relativeFileOrPattern = isProjectRootSameAsWorkspace
? fileOrPattern
: normalizePath(join(relativeProjectRootPath, fileOrPattern));
const absoluteFileOrPattern = new RelativePattern(this.workspaceFolder, relativeFileOrPattern);
this.logger.debug(
() =>
`Creating file watcher for file or pattern '${fileOrPattern}' ` +
`using base path: ${absoluteFileOrPattern.base}`
);
const fileWatcher = workspace.createFileSystemWatcher(absoluteFileOrPattern);
fileWatchers.push(fileWatcher);
this.disposables.push(
fileWatcher.onDidChange(fileUri => handler(normalizePath(fileUri.fsPath), FileChangeType.Changed)),
fileWatcher.onDidCreate(fileUri => handler(normalizePath(fileUri.fsPath), FileChangeType.Created)),
fileWatcher.onDidDelete(fileUri => handler(normalizePath(fileUri.fsPath), FileChangeType.Deleted))
);
}
return fileWatchers;
}
Example #6
Source File: workspace.ts From vscode-code-review with MIT License | 5 votes |
private fileWatcher!: FileSystemWatcher;
Example #7
Source File: MockDendronExtension.ts From dendron with GNU Affero General Public License v3.0 | 5 votes |
serverWatcher?: FileSystemWatcher | undefined;
Example #8
Source File: dbtWorkspaceFolder.ts From vscode-dbt-power-user with MIT License | 5 votes |
private watcher: FileSystemWatcher;
Example #9
Source File: dbtProjectLog.ts From vscode-dbt-power-user with MIT License | 5 votes |
private logFileWatcher?: FileSystemWatcher;
Example #10
Source File: sourceFileWatchers.ts From vscode-dbt-power-user with MIT License | 5 votes |
private watchers: FileSystemWatcher[] = [];
Example #11
Source File: targetWatchers.ts From vscode-dbt-power-user with MIT License | 5 votes |
private manifestWatcher?: FileSystemWatcher;
Example #12
Source File: targetWatchers.ts From vscode-dbt-power-user with MIT License | 5 votes |
private targetFolderWatcher?: FileSystemWatcher;
Example #13
Source File: targetWatchers.ts From vscode-dbt-power-user with MIT License | 5 votes |
private watchers: FileSystemWatcher[] = [];
Example #14
Source File: FileWatcher.ts From al-objid with MIT License | 5 votes |
private readonly _watcher: FileSystemWatcher;
Example #15
Source File: FileWatcher.ts From al-objid with MIT License | 5 votes |
private _gitWatcher: FileSystemWatcher | undefined;