提交 5d610028 编写于 作者: D Daniel Imms

Watch directory and watch resolved symlinks if they exist

上级 332b6739
...@@ -96,22 +96,28 @@ export class UserSettings { ...@@ -96,22 +96,28 @@ export class UserSettings {
self.watcher.on('change', (eventType: string, fileName: string) => self.onSettingsFileChange(eventType, fileName)); self.watcher.on('change', (eventType: string, fileName: string) => self.onSettingsFileChange(eventType, fileName));
} }
let settingsDir = path.dirname(this.appSettingsPath); // Attach a watcher to the settings directory
let settingsPath = path.join(settingsDir, 'settings.json'); attachSettingsChangeWatcher(path.dirname(this.appSettingsPath));
fs.lstat(settingsPath, function(err, stats) {
if (err) { // Follow symlinks for settings and keybindings and attach watchers if they resolve
// Attach to the directory if the file doesn't exist let followSymlinkPaths = [
attachSettingsChangeWatcher(settingsDir); this.appSettingsPath,
} else if (stats.isSymbolicLink()) { this.appKeybindingsPath
fs.readlink(self.appSettingsPath, function(err, realPath) { ];
if (err) { followSymlinkPaths.forEach((path) => {
attachSettingsChangeWatcher(self.appSettingsPath); fs.lstat(path, function(err, stats) {
} if (err) {
attachSettingsChangeWatcher(realPath); return;
}); }
} else { if (stats.isSymbolicLink()) {
attachSettingsChangeWatcher(self.appSettingsPath); fs.readlink(path, function(err, realPath) {
} if (err) {
return;
}
attachSettingsChangeWatcher(realPath);
});
}
});
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册