forked from phcode-dev/staging.phcode.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPreferencesImpl.js
More file actions
1 lines (1 loc) · 2.19 KB
/
Copy pathPreferencesImpl.js
File metadata and controls
1 lines (1 loc) · 2.19 KB
1
define(function(require,exports,module){const PreferencesBase=require("./PreferencesBase"),Async=require("utils/Async"),SETTINGS_FILENAME="phcode.json",SETTINGS_FILENAME_BRACKETS="brackets.json",STATE_FILENAME="state.json",userPrefFile=path.normalize(brackets.app.getApplicationSupportDirectory()+"/phcode.json");var _prefManagerReadyDeferred=new $.Deferred,userScopeCorrupt=!1;function isUserScopeCorrupt(){return userScopeCorrupt}var _addScopePromises=[],manager=new PreferencesBase.PreferencesSystem;manager.pauseChangeEvents();var projectStorage=new PreferencesBase.FileStorage(void 0,!0),projectScope=new PreferencesBase.Scope(projectStorage),projectPathLayer=new PreferencesBase.PathLayer,projectLanguageLayer=new PreferencesBase.LanguageLayer;projectScope.addLayer(projectPathLayer),projectScope.addLayer(projectLanguageLayer);var userStorage=new PreferencesBase.FileStorage(userPrefFile,!0),userScope=new PreferencesBase.Scope(userStorage),userLanguageLayer=new PreferencesBase.LanguageLayer;userScope.addLayer(userLanguageLayer);var userScopeLoading=manager.addScope("user",userScope);function _reloadUserPrefs(rootDir){var prefsDir;0===path.normalize(brackets.app.getApplicationSupportDirectory()+"/").indexOf(rootDir.fullPath)&&manager.fileChanged(userPrefFile)}_addScopePromises.push(userScopeLoading),userScopeLoading.fail(function(err){_addScopePromises.push(manager.addScope("user",new PreferencesBase.MemoryStorage,{before:"default"})),err.name&&"ParsingError"===err.name&&(userScopeCorrupt=!0)}).always(function(){_addScopePromises.push(manager.addScope("project",projectScope,{before:"user"})),_addScopePromises.push(manager.addScope("session",new PreferencesBase.MemoryStorage)),Async.waitForAll(_addScopePromises).always(function(){_prefManagerReadyDeferred.resolve()})}),exports.manager=manager,exports.projectStorage=projectStorage,exports.projectPathLayer=projectPathLayer,exports.userScopeLoading=userScopeLoading,exports.userPrefFile=userPrefFile,exports.isUserScopeCorrupt=isUserScopeCorrupt,exports.managerReady=_prefManagerReadyDeferred.promise(),exports.reloadUserPrefs=_reloadUserPrefs,exports.STATE_FILENAME="state.json",exports.SETTINGS_FILENAME="phcode.json",exports.SETTINGS_FILENAME_BRACKETS="brackets.json"});