提交 8104e9f0 编写于 作者: B Benjamin Pasero

💄

上级 19fd2b50
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { join, basename } from 'vs/base/common/path'; import { join, basename } from 'vs/base/common/path';
import * as fs from 'fs'; import { watch } from 'fs';
import * as platform from 'vs/base/common/platform'; import { isMacintosh } from 'vs/base/common/platform';
import { normalizeNFC } from 'vs/base/common/normalization'; import { normalizeNFC } from 'vs/base/common/normalization';
import { toDisposable, IDisposable, dispose } from 'vs/base/common/lifecycle'; import { toDisposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
import { exists, readdir } from 'vs/base/node/pfs'; import { exists, readdir } from 'vs/base/node/pfs';
...@@ -33,7 +33,7 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha ...@@ -33,7 +33,7 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha
try { try {
// Creating watcher can fail with an exception // Creating watcher can fail with an exception
const watcher = fs.watch(file.path); const watcher = watch(file.path);
watcherDisposables.push(toDisposable(() => { watcherDisposables.push(toDisposable(() => {
watcher.removeAllListeners(); watcher.removeAllListeners();
watcher.close(); watcher.close();
...@@ -60,7 +60,7 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha ...@@ -60,7 +60,7 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha
let changedFileName: string = ''; let changedFileName: string = '';
if (raw) { // https://github.com/Microsoft/vscode/issues/38191 if (raw) { // https://github.com/Microsoft/vscode/issues/38191
changedFileName = raw.toString(); changedFileName = raw.toString();
if (platform.isMacintosh) { if (isMacintosh) {
// Mac: uses NFD unicode form on disk, but we want NFC // Mac: uses NFD unicode form on disk, but we want NFC
// See also https://github.com/nodejs/node/issues/2165 // See also https://github.com/nodejs/node/issues/2165
changedFileName = normalizeNFC(changedFileName); changedFileName = normalizeNFC(changedFileName);
...@@ -177,7 +177,7 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha ...@@ -177,7 +177,7 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha
} }
}); });
} catch (error) { } catch (error) {
fs.exists(file.path, exists => { exists(file.path).then(exists => {
if (exists && !disposed) { if (exists && !disposed) {
onError(`Failed to watch ${file.path} for changes using fs.watch() (${error.toString()})`); onError(`Failed to watch ${file.path} for changes using fs.watch() (${error.toString()})`);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册