in src/server/project.js [318:364]
Project.prototype._getProjectState = function() {
let platform = this.platform;
let projectRoot = this.projectRoot;
let newState = {};
// Get the list of plugins for the current platform.
let pluginsJsonPath = path.join(projectRoot, 'plugins', platform + '.json');
return fs.promises.readFile(pluginsJsonPath)
.catch(function () {
// an error ocurred trying to read the file for the current platform,
// return an empty json file content
return '{}';
})
.then(function (fileContent) {
let installedPlugins;
try {
installedPlugins = Object.keys(JSON.parse(fileContent.toString())['installed_plugins'] || {});
} catch (err) {
// For some reason, it was not possible to determine which plugins are installed for the current platform, so
// use a dummy value to indicate a "bad state".
installedPlugins = ['__unknown__'];
}
newState.pluginList = installedPlugins;
})
.then(function () {
// Get the modification times for project files.
let wwwRoot = path.join(projectRoot, 'www');
let mergesRoot = path.join(projectRoot, 'merges', platform);
return Promise.all([utils.getMtimeForFiles(wwwRoot), utils.getMtimeForFiles(mergesRoot)]);
})
.then(function ([wwwFiles, mergesFiles]) {
var files = {};
files.www = wwwFiles || {};
files.merges = mergesFiles || {};
newState.files = files;
// Get information about current debug-host handlers.
newState.debugHostHandlers = this._simulatorProxy.config.debugHostHandlers || [];
// Return the new state.
return newState;
}.bind(this));
};