aboutsummaryrefslogtreecommitdiff
path: root/editors/vscode/src/watch.ts
blob: 5488bb3583b3f7d68d61fa192f3ca1d224d0427f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import * as vscode from "vscode";
import { Ctx } from "./ctx";
import { parseOlsFile } from "./extension";
import { log } from "./util";

export function watchOlsConfigFile(ctx: Ctx, olsFile: string) 
{
    var olsWatcher = vscode.workspace.createFileSystemWatcher(olsFile);

    olsWatcher.onDidCreate(async (uri) => {
        log.info("ols.json modified - restarting client");
        await parseOlsFile(ctx.config, uri.fsPath);
        vscode.commands.executeCommand("ols.restart");
    });

    olsWatcher.onDidChange(async (uri) => {
        log.info("ols.json modified - restarting client");
        await parseOlsFile(ctx.config, uri.fsPath);
        vscode.commands.executeCommand("ols.restart");
    });

}