Skip to content

Commit

Permalink
handle adding new file
Browse files Browse the repository at this point in the history
  • Loading branch information
HerringtonDarkholme committed Feb 20, 2018
1 parent d342dff commit a7f9248
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions server/src/modes/script/serviceHost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ export function getServiceHost(workspacePath: string, jsDocuments: LanguageModel
ignored: defaultIgnorePatterns(workspacePath)
});

watcher.on('change', function (path: string) {
if (!/(tsx?|vue|jsx?)$/.test(path)) {
return;
}
const ver = versions.get(path) || 0;
versions.set(path, ver + 1);
});
watcher
.on('change', filterNonScript(path => {
const ver = versions.get(path) || 0;
versions.set(path, ver + 1);
}))
.on('add', filterNonScript(path => {
files.push(path);
}));

function updateCurrentTextDocument(doc: TextDocument) {
const fileFsPath = getFileFsPath(doc.uri);
Expand Down Expand Up @@ -273,3 +274,12 @@ function getParsedConfig(workspacePath: string) {
[{ extension: 'vue', isMixedContent: true }]
);
}

function filterNonScript(func: (path: string) => void) {
return (path: string) => {
if (!/(tsx?|vue|jsx?)$/.test(path)) {
return;
}
func(path);
};
}

0 comments on commit a7f9248

Please sign in to comment.