Replace pathwatcher w/ bundled watcher to catch created & rename events

This commit is contained in:
Katrina Uychaco
2017-08-23 17:43:47 -07:00
parent 236d9011c8
commit 7c3fe7dba4

View File

@@ -4,7 +4,7 @@ fs = require 'fs-plus'
CSON = require 'season'
path = require 'path'
async = require 'async'
pathWatcher = require 'pathwatcher'
{watchPath} = require './path-watcher'
{
getValueAtKeyPath, setValueAtKeyPath, deleteValueAtKeyPath,
pushKeyPath, splitKeyPath,
@@ -880,8 +880,9 @@ class Config
return if @shouldNotAccessFileSystem()
try
@watchSubscription ?= pathWatcher.watch @configFilePath, (eventType) =>
@requestLoad() if eventType is 'change' and @watchSubscription?
@watchSubscription ?= watchPath @configFilePath, {}, (events) =>
for {action} in events
@requestLoad() if action in ['created', 'modified', 'renamed'] and @watchSubscription?
catch error
@notifyFailure """
Unable to watch path: `#{path.basename(@configFilePath)}`. Make sure you have permissions to
@@ -891,7 +892,7 @@ class Config
"""
unobserveUserConfig: ->
@watchSubscription?.close()
@watchSubscription?.dispose()
@watchSubscription = null
notifyFailure: (errorMessage, detail) ->