From ca7b492b97cb754561646d1b332742f57201dab9 Mon Sep 17 00:00:00 2001 From: Zeke Sikelianos Date: Fri, 25 Mar 2016 12:41:24 -0700 Subject: [PATCH] tiptoeing along, keeping the suite passing --- lib/common/api/callbacks-registry.js | 68 +++++++++--------- lib/common/api/clipboard.js | 4 +- lib/common/api/crash-reporter.js | 103 ++++++++++++++------------- 3 files changed, 90 insertions(+), 85 deletions(-) diff --git a/lib/common/api/callbacks-registry.js b/lib/common/api/callbacks-registry.js index d5cfd2da8399..c8b8579601da 100644 --- a/lib/common/api/callbacks-registry.js +++ b/lib/common/api/callbacks-registry.js @@ -1,62 +1,62 @@ -'use strict'; +'use strict' -const v8Util = process.atomBinding('v8_util'); +const v8Util = process.atomBinding('v8_util') class CallbacksRegistry { - constructor() { - this.nextId = 0; - this.callbacks = {}; + constructor () { + this.nextId = 0 + this.callbacks = {} } - add(callback) { + add (callback) { // The callback is already added. - var filenameAndLine, id, location, match, ref, regexp, stackString; - id = v8Util.getHiddenValue(callback, 'callbackId'); + var filenameAndLine, id, location, match, ref, regexp, stackString + id = v8Util.getHiddenValue(callback, 'callbackId') if (id != null) { - return id; + return id } - id = ++this.nextId; + id = ++this.nextId // Capture the location of the function and put it in the ID string, // so that release errors can be tracked down easily. - regexp = /at (.*)/gi; - stackString = (new Error).stack; + regexp = /at (.*)/gi + stackString = (new Error).stack while ((match = regexp.exec(stackString)) !== null) { - location = match[1]; + location = match[1] if (location.indexOf('(native)') !== -1) { - continue; + continue } if (location.indexOf('atom.asar') !== -1) { - continue; + continue } - ref = /([^\/^\)]*)\)?$/gi.exec(location); - filenameAndLine = ref[1]; - break; + ref = /([^\/^\)]*)\)?$/gi.exec(location) + filenameAndLine = ref[1] + break } - this.callbacks[id] = callback; - v8Util.setHiddenValue(callback, 'callbackId', id); - v8Util.setHiddenValue(callback, 'location', filenameAndLine); - return id; + this.callbacks[id] = callback + v8Util.setHiddenValue(callback, 'callbackId', id) + v8Util.setHiddenValue(callback, 'location', filenameAndLine) + return id } - get(id) { - var ref; - return (ref = this.callbacks[id]) != null ? ref : function() {}; + get (id) { + var ref + return (ref = this.callbacks[id]) != null ? ref : function () {} } - call(id, ...args) { - var ref; - return (ref = this.get(id)).call.apply(ref, [global].concat(args)); + call (id, ...args) { + var ref + return (ref = this.get(id)).call.apply(ref, [global].concat(args)) } - apply(id, ...args) { - var ref; - return (ref = this.get(id)).apply.apply(ref, [global].concat(args)); + apply (id, ...args) { + var ref + return (ref = this.get(id)).apply.apply(ref, [global].concat(args)) } - remove(id) { - return delete this.callbacks[id]; + remove (id) { + return delete this.callbacks[id] } } -module.exports = CallbacksRegistry; +module.exports = CallbacksRegistry diff --git a/lib/common/api/clipboard.js b/lib/common/api/clipboard.js index cd1cb53e4001..7186f8b63412 100644 --- a/lib/common/api/clipboard.js +++ b/lib/common/api/clipboard.js @@ -1,6 +1,6 @@ if (process.platform === 'linux' && process.type === 'renderer') { // On Linux we could not access clipboard in renderer process. - module.exports = require('electron').remote.clipboard; + module.exports = require('electron').remote.clipboard } else { - module.exports = process.atomBinding('clipboard'); + module.exports = process.atomBinding('clipboard') } diff --git a/lib/common/api/crash-reporter.js b/lib/common/api/crash-reporter.js index f84e13ebb57f..25054b72527d 100644 --- a/lib/common/api/crash-reporter.js +++ b/lib/common/api/crash-reporter.js @@ -1,94 +1,99 @@ -'use strict'; +'use strict' -const os = require('os'); -const path = require('path'); -const spawn = require('child_process').spawn; -const electron = require('electron'); -const binding = process.atomBinding('crash_reporter'); +const os = require('os') +const path = require('path') +const spawn = require('child_process').spawn +const electron = require('electron') +const binding = process.atomBinding('crash_reporter') -var CrashReporter = (function() { - function CrashReporter() {} +var CrashReporter = (function () { + function CrashReporter () {} - CrashReporter.prototype.start = function(options) { - var app, args, autoSubmit, companyName, deprecate, env, extra, ignoreSystemCrashHandler, start, submitURL; + CrashReporter.prototype.start = function (options) { + var app, args, autoSubmit, companyName, deprecate, env, extra, ignoreSystemCrashHandler, start, submitURL if (options == null) { - options = {}; + options = {} } - this.productName = options.productName, companyName = options.companyName, submitURL = options.submitURL, autoSubmit = options.autoSubmit, ignoreSystemCrashHandler = options.ignoreSystemCrashHandler, extra = options.extra; + this.productName = options.productName + companyName = options.companyName + submitURL = options.submitURL + autoSubmit = options.autoSubmit + ignoreSystemCrashHandler = options.ignoreSystemCrashHandler + extra = options.extra // Deprecated. - deprecate = electron.deprecate; + deprecate = electron.deprecate if (options.submitUrl) { if (submitURL == null) { - submitURL = options.submitUrl; + submitURL = options.submitUrl } - deprecate.warn('submitUrl', 'submitURL'); + deprecate.warn('submitUrl', 'submitURL') } - app = (process.type === 'browser' ? electron : electron.remote).app; + app = (process.type === 'browser' ? electron : electron.remote).app if (this.productName == null) { - this.productName = app.getName(); + this.productName = app.getName() } if (autoSubmit == null) { - autoSubmit = true; + autoSubmit = true } if (ignoreSystemCrashHandler == null) { - ignoreSystemCrashHandler = false; + ignoreSystemCrashHandler = false } if (extra == null) { - extra = {}; + extra = {} } if (extra._productName == null) { - extra._productName = this.productName; + extra._productName = this.productName } if (extra._companyName == null) { - extra._companyName = companyName; + extra._companyName = companyName } if (extra._version == null) { - extra._version = app.getVersion(); + extra._version = app.getVersion() } if (companyName == null) { - deprecate.log('companyName is now a required option to crashReporter.start'); - return; + deprecate.log('companyName is now a required option to crashReporter.start') + return } if (submitURL == null) { - deprecate.log('submitURL is now a required option to crashReporter.start'); - return; + deprecate.log('submitURL is now a required option to crashReporter.start') + return } start = () => { - binding.start(this.productName, companyName, submitURL, autoSubmit, ignoreSystemCrashHandler, extra); - }; + binding.start(this.productName, companyName, submitURL, autoSubmit, ignoreSystemCrashHandler, extra) + } if (process.platform === 'win32') { - args = ["--reporter-url=" + submitURL, "--application-name=" + this.productName, "--v=1"]; + args = ["--reporter-url=" + submitURL, "--application-name=" + this.productName, "--v=1"] env = { ATOM_SHELL_INTERNAL_CRASH_SERVICE: 1 - }; + } spawn(process.execPath, args, { env: env, detached: true - }); + }) } - return start(); - }; + return start() + } - CrashReporter.prototype.getLastCrashReport = function() { - var reports; - reports = this.getUploadedReports(); + CrashReporter.prototype.getLastCrashReport = function () { + var reports + reports = this.getUploadedReports() if (reports.length > 0) { - return reports[0]; + return reports[0] } else { - return null; + return null } - }; + } - CrashReporter.prototype.getUploadedReports = function() { - var log, tmpdir; - tmpdir = process.platform === 'win32' ? os.tmpdir() : '/tmp'; - log = process.platform === 'darwin' ? path.join(tmpdir, this.productName + " Crashes") : path.join(tmpdir, this.productName + " Crashes", 'uploads.log'); - return binding._getUploadedReports(log); - }; + CrashReporter.prototype.getUploadedReports = function () { + var log, tmpdir + tmpdir = process.platform === 'win32' ? os.tmpdir() : '/tmp' + log = process.platform === 'darwin' ? path.join(tmpdir, this.productName + " Crashes") : path.join(tmpdir, this.productName + " Crashes", 'uploads.log') + return binding._getUploadedReports(log) + } - return CrashReporter; + return CrashReporter -})(); +})() -module.exports = new CrashReporter; +module.exports = new CrashReporter