From ada9f85316dd541887fdd56a607ba8465dc1bdf6 Mon Sep 17 00:00:00 2001 From: Alhadis Date: Wed, 21 Mar 2018 23:54:57 +1100 Subject: [PATCH] Remove logic for loading a user's editor settings Atom v1.25.0 changed how user configs were updated on disk, subsequently removing some properties which we were relying on to find `config.cson`. This is causing `loadEditorSettings` to raise an exception at startup. Since this feature was headed for the incinerator anyway, we may as well cull it early (it was a stupid idea to begin with, among many others yet to be obliterated). See Alhadis/Atom-Mocha#3. --- lib/reporter.js | 51 +------------------------------------------------ 1 file changed, 1 insertion(+), 50 deletions(-) diff --git a/lib/reporter.js b/lib/reporter.js index de34c91..9c0b844 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -665,7 +665,7 @@ class Reporter{ * @return {Promise} */ static beforeStart(main){ - const promises = [this.loadEditorSettings()]; + const promises = []; // Load JavaScript grammar to provide syntax highlighting if(main.options.formatCode){ @@ -681,55 +681,6 @@ class Reporter{ return Promise.all(promises); } - - - - /** - * Attempt to load user's config to improve feedback quality. - * - * User configs are parsed statically. Because this feature is so cosmetic, - * it's not worth adding CSON/CoffeeScript as a hard dependency over. - * - * @return {Promise} - */ - static loadEditorSettings(){ - - return new Promise((resolve, reject) => { - const configPath = atom.config.configFilePath; - - fs.readFile(configPath, (error, data) => { - if(error) return reject(error); - - // Break the config's content apart by top-level scope - const scopes = {}; - data.toString().split(/^(?=\S)/gm).forEach(s => { - const scope = /^(?:"(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+'|\w+)/; - const editor = /\n {2}editor:\n[^\x00]+?\n(?: {2}\S|$)/; - const ed = (s.match(editor) || [""])[0]; - - // Pinch a bunch of parsed editor settings - if(s = (s.match(scope) || [""])[0].replace(/["']/g, "")) - scopes[s] = { - fontFamily: (ed.match(/^ +fontFamily:\s*("|')(.+)\1/im) || []).pop(), - fontSize: (ed.match(/^ +fontSize:\s*([\d.]+)/im) || []).pop(), - lineHeight: (ed.match(/^ +lineHeight:\s*([\d.]+)/im) || []).pop(), - tabLength: (ed.match(/^ +tabLength:\s*(\d+)/im) || []).pop() - }; - }); - - // Now collate them in ascending order of precedence - const ed = {}; - for(let scope of ["*", ".atom-mocha"]){ - for(let k in scopes[scope]){ - let v = scopes[scope][k] - if(v != null) ed[k] = v - } - } - Reporter.editorSettings = ed; - resolve(); - }); - }); - } }