autoformat more easy files

This commit is contained in:
Zeke Sikelianos 2016-03-25 12:50:33 -07:00 committed by Kevin Sawicki
parent 80f7c82f93
commit c845ea8372
5 changed files with 99 additions and 101 deletions

View file

@ -1,108 +1,108 @@
// Deprecate a method. // Deprecate a method.
const deprecate = function(oldName, newName, fn) { const deprecate = function (oldName, newName, fn) {
var warned; var warned
warned = false; warned = false
return function() { return function () {
if (!(warned || process.noDeprecation)) { if (!(warned || process.noDeprecation)) {
warned = true; warned = true
deprecate.warn(oldName, newName); deprecate.warn(oldName, newName)
} }
return fn.apply(this, arguments); return fn.apply(this, arguments)
}; }
}; }
// The method is renamed. // The method is renamed.
deprecate.rename = function(object, oldName, newName) { deprecate.rename = function (object, oldName, newName) {
var newMethod, warned; var newMethod, warned
warned = false; warned = false
newMethod = function() { newMethod = function () {
if (!(warned || process.noDeprecation)) { if (!(warned || process.noDeprecation)) {
warned = true; warned = true
deprecate.warn(oldName, newName); deprecate.warn(oldName, newName)
} }
return this[newName].apply(this, arguments); return this[newName].apply(this, arguments)
};
if (typeof object === 'function') {
return object.prototype[oldName] = newMethod;
} else {
return object[oldName] = newMethod;
} }
}; if (typeof object === 'function') {
return object.prototype[oldName] = newMethod
} else {
return object[oldName] = newMethod
}
}
// Forward the method to member. // Forward the method to member.
deprecate.member = function(object, method, member) { deprecate.member = function (object, method, member) {
var warned; var warned
warned = false; warned = false
return object.prototype[method] = function() { return object.prototype[method] = function () {
if (!(warned || process.noDeprecation)) { if (!(warned || process.noDeprecation)) {
warned = true; warned = true
deprecate.warn(method, member + "." + method); deprecate.warn(method, member + '.' + method)
} }
return this[member][method].apply(this[member], arguments); return this[member][method].apply(this[member], arguments)
}; }
}; }
// Deprecate a property. // Deprecate a property.
deprecate.property = function(object, property, method) { deprecate.property = function (object, property, method) {
return Object.defineProperty(object, property, { return Object.defineProperty(object, property, {
get: function() { get: function () {
var warned; var warned
warned = false; warned = false
if (!(warned || process.noDeprecation)) { if (!(warned || process.noDeprecation)) {
warned = true; warned = true
deprecate.warn(property + " property", method + " method"); deprecate.warn(property + ' property', method + ' method')
} }
return this[method](); return this[method]()
} }
}); })
}; }
// Deprecate an event. // Deprecate an event.
deprecate.event = function(emitter, oldName, newName, fn) { deprecate.event = function (emitter, oldName, newName, fn) {
var warned; var warned
warned = false; warned = false
return emitter.on(newName, function(...args) { return emitter.on(newName, function (...args) {
// there is listeners for old API. // there is listeners for old API.
if (this.listenerCount(oldName) > 0) { if (this.listenerCount(oldName) > 0) {
if (!(warned || process.noDeprecation)) { if (!(warned || process.noDeprecation)) {
warned = true; warned = true
deprecate.warn("'" + oldName + "' event", "'" + newName + "' event"); deprecate.warn("'" + oldName + "' event", "'" + newName + "' event")
} }
if (fn != null) { if (fn != null) {
return fn.apply(this, arguments); return fn.apply(this, arguments)
} else { } else {
return this.emit.apply(this, [oldName].concat(args)); return this.emit.apply(this, [oldName].concat(args))
} }
} }
}); })
}; }
// Print deprecation warning. // Print deprecation warning.
deprecate.warn = function(oldName, newName) { deprecate.warn = function (oldName, newName) {
return deprecate.log(oldName + " is deprecated. Use " + newName + " instead."); return deprecate.log(oldName + ' is deprecated. Use ' + newName + ' instead.')
}; }
var deprecationHandler = null; var deprecationHandler = null
// Print deprecation message. // Print deprecation message.
deprecate.log = function(message) { deprecate.log = function (message) {
if (typeof deprecationHandler === 'function') { if (typeof deprecationHandler === 'function') {
deprecationHandler(message); deprecationHandler(message)
} else if (process.throwDeprecation) { } else if (process.throwDeprecation) {
throw new Error(message); throw new Error(message)
} else if (process.traceDeprecation) { } else if (process.traceDeprecation) {
return console.trace(message); return console.trace(message)
} else { } else {
return console.warn("(electron) " + message); return console.warn('(electron) ' + message)
} }
}; }
deprecate.setHandler = function(handler) { deprecate.setHandler = function (handler) {
deprecationHandler = handler; deprecationHandler = handler
}; }
deprecate.getHandler = function() { deprecate.getHandler = function () {
return deprecationHandler; return deprecationHandler
}; }
module.exports = deprecate; module.exports = deprecate

View file

@ -1,11 +1,11 @@
'use strict'; 'use strict'
const deprecate = require('electron').deprecate; const deprecate = require('electron').deprecate
exports.setHandler = function (deprecationHandler) { exports.setHandler = function (deprecationHandler) {
deprecate.setHandler(deprecationHandler); deprecate.setHandler(deprecationHandler)
}; }
exports.getHandler = function () { exports.getHandler = function () {
return deprecate.getHandler(); return deprecate.getHandler()
}; }

View file

@ -1,15 +1,14 @@
// Do not expose the internal modules to `require`. // Do not expose the internal modules to `require`.
const hideInternalModules = function() { const hideInternalModules = function () {
var globalPaths = require('module').globalPaths; var globalPaths = require('module').globalPaths
if (globalPaths.length === 3) { if (globalPaths.length === 3) {
// Remove the "common/api/lib" and "browser-or-renderer/api/lib". // Remove the "common/api/lib" and "browser-or-renderer/api/lib".
return globalPaths.splice(0, 2); return globalPaths.splice(0, 2)
} }
}; }
// Attaches properties to |exports|. // Attaches properties to |exports|.
exports.defineProperties = function(exports) { exports.defineProperties = function (exports) {
return Object.defineProperties(exports, { return Object.defineProperties(exports, {
hideInternalModules: { hideInternalModules: {
enumerable: true, enumerable: true,
@ -18,48 +17,47 @@ exports.defineProperties = function(exports) {
// Common modules, please sort with alphabet order. // Common modules, please sort with alphabet order.
clipboard: { clipboard: {
// Must be enumerable, otherwise it woulde be invisible to remote module. // Must be enumerable, otherwise it woulde be invisible to remote module.
enumerable: true, enumerable: true,
get: function() { get: function () {
return require('../clipboard'); return require('../clipboard')
} }
}, },
crashReporter: { crashReporter: {
enumerable: true, enumerable: true,
get: function() { get: function () {
return require('../crash-reporter'); return require('../crash-reporter')
} }
}, },
deprecations: { deprecations: {
enumerable: true, enumerable: true,
get: function() { get: function () {
return require('../deprecations'); return require('../deprecations')
} }
}, },
nativeImage: { nativeImage: {
enumerable: true, enumerable: true,
get: function() { get: function () {
return require('../native-image'); return require('../native-image')
} }
}, },
shell: { shell: {
enumerable: true, enumerable: true,
get: function() { get: function () {
return require('../shell'); return require('../shell')
} }
}, },
// The internal modules, invisible unless you know their names. // The internal modules, invisible unless you know their names.
CallbacksRegistry: { CallbacksRegistry: {
get: function() { get: function () {
return require('../callbacks-registry'); return require('../callbacks-registry')
} }
}, },
deprecate: { deprecate: {
get: function() { get: function () {
return require('../deprecate'); return require('../deprecate')
} }
} }
}); })
}; }

View file

@ -1,7 +1,7 @@
const deprecate = require('electron').deprecate; const deprecate = require('electron').deprecate
const nativeImage = process.atomBinding('native_image'); const nativeImage = process.atomBinding('native_image')
// Deprecated. // Deprecated.
deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL'); deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL')
module.exports = nativeImage; module.exports = nativeImage

View file

@ -1 +1 @@
module.exports = process.atomBinding('shell'); module.exports = process.atomBinding('shell')