chore: remove duplicate internal deprecations module (just use deprecate) (#18352)

This commit is contained in:
Milan Burda 2019-05-21 00:40:49 +02:00 committed by Alexey Kuzmin
parent 9c21c66b97
commit c1cccfc082
4 changed files with 15 additions and 28 deletions

View file

@ -49,7 +49,6 @@ filenames = {
"lib/browser/utils.ts", "lib/browser/utils.ts",
"lib/common/api/clipboard.js", "lib/common/api/clipboard.js",
"lib/common/api/deprecate.ts", "lib/common/api/deprecate.ts",
"lib/common/api/deprecations.js",
"lib/common/api/is-promise.js", "lib/common/api/is-promise.js",
"lib/common/api/exports/electron.js", "lib/common/api/exports/electron.js",
"lib/common/api/module-list.js", "lib/common/api/module-list.js",

View file

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

View file

@ -7,6 +7,5 @@ module.exports = [
{ name: 'shell', file: 'shell' }, { name: 'shell', file: 'shell' },
// The internal modules, invisible unless you know their names. // The internal modules, invisible unless you know their names.
{ name: 'deprecate', file: 'deprecate', private: true }, { name: 'deprecate', file: 'deprecate', private: true },
{ name: 'deprecations', file: 'deprecations', private: true },
{ name: 'isPromise', file: 'is-promise', private: true } { name: 'isPromise', file: 'is-promise', private: true }
] ]

View file

@ -2,21 +2,21 @@
const chai = require('chai') const chai = require('chai')
const dirtyChai = require('dirty-chai') const dirtyChai = require('dirty-chai')
const { deprecations, deprecate } = require('electron') const { deprecate } = require('electron')
const { expect } = chai const { expect } = chai
chai.use(dirtyChai) chai.use(dirtyChai)
describe('deprecations', () => { describe('deprecate', () => {
beforeEach(() => { beforeEach(() => {
deprecations.setHandler(null) deprecate.setHandler(null)
process.throwDeprecation = true process.throwDeprecation = true
}) })
it('allows a deprecation handler function to be specified', () => { it('allows a deprecation handler function to be specified', () => {
const messages = [] const messages = []
deprecations.setHandler(message => { deprecate.setHandler(message => {
messages.push(message) messages.push(message)
}) })
@ -27,17 +27,17 @@ describe('deprecations', () => {
it('returns a deprecation handler after one is set', () => { it('returns a deprecation handler after one is set', () => {
const messages = [] const messages = []
deprecations.setHandler(message => { deprecate.setHandler(message => {
messages.push(message) messages.push(message)
}) })
deprecate.log('this is deprecated') deprecate.log('this is deprecated')
expect(deprecations.getHandler()).to.be.a('function') expect(deprecate.getHandler()).to.be.a('function')
}) })
it('renames a property', () => { it('renames a property', () => {
let msg let msg
deprecations.setHandler(m => { msg = m }) deprecate.setHandler(m => { msg = m })
const oldProp = 'dingyOldName' const oldProp = 'dingyOldName'
const newProp = 'shinyNewName' const newProp = 'shinyNewName'
@ -68,7 +68,7 @@ describe('deprecations', () => {
it('deprecates a property of an object', () => { it('deprecates a property of an object', () => {
let msg let msg
deprecations.setHandler(m => { msg = m }) deprecate.setHandler(m => { msg = m })
const prop = 'itMustGo' const prop = 'itMustGo'
const o = { [prop]: 0 } const o = { [prop]: 0 }
@ -84,7 +84,7 @@ describe('deprecations', () => {
it('warns exactly once when a function is deprecated with no replacement', () => { it('warns exactly once when a function is deprecated with no replacement', () => {
let msg let msg
deprecations.setHandler(m => { msg = m }) deprecate.setHandler(m => { msg = m })
function oldFn () { return 'hello' } function oldFn () { return 'hello' }
const deprecatedFn = deprecate.function(oldFn) const deprecatedFn = deprecate.function(oldFn)
@ -96,7 +96,7 @@ describe('deprecations', () => {
it('warns exactly once when a function is deprecated with a replacement', () => { it('warns exactly once when a function is deprecated with a replacement', () => {
let msg let msg
deprecations.setHandler(m => { msg = m }) deprecate.setHandler(m => { msg = m })
function oldFn () { return 'hello' } function oldFn () { return 'hello' }
function newFn () { return 'goodbye' } function newFn () { return 'goodbye' }
@ -110,7 +110,7 @@ describe('deprecations', () => {
it('warns only once per item', () => { it('warns only once per item', () => {
const messages = [] const messages = []
deprecations.setHandler(message => messages.push(message)) deprecate.setHandler(message => messages.push(message))
const key = 'foo' const key = 'foo'
const val = 'bar' const val = 'bar'
@ -125,7 +125,7 @@ describe('deprecations', () => {
it('warns if deprecated property is already set', () => { it('warns if deprecated property is already set', () => {
let msg let msg
deprecations.setHandler(m => { msg = m }) deprecate.setHandler(m => { msg = m })
const oldProp = 'dingyOldName' const oldProp = 'dingyOldName'
const newProp = 'shinyNewName' const newProp = 'shinyNewName'
@ -146,7 +146,7 @@ describe('deprecations', () => {
it('warns when a function is deprecated in favor of a property', () => { it('warns when a function is deprecated in favor of a property', () => {
const warnings = [] const warnings = []
deprecations.setHandler(warning => warnings.push(warning)) deprecate.setHandler(warning => warnings.push(warning))
const newProp = 'newProp' const newProp = 'newProp'
const mod = { const mod = {
@ -175,12 +175,12 @@ describe('deprecations', () => {
const enableCallbackWarnings = () => { const enableCallbackWarnings = () => {
warnings = [] warnings = []
deprecations.setHandler(warning => warnings.push(warning)) deprecate.setHandler(warning => warnings.push(warning))
process.enablePromiseAPIs = true process.enablePromiseAPIs = true
} }
beforeEach(() => { beforeEach(() => {
deprecations.setHandler(null) deprecate.setHandler(null)
process.throwDeprecation = true process.throwDeprecation = true
promiseFunc = param => new Promise((resolve, reject) => resolve(param)) promiseFunc = param => new Promise((resolve, reject) => resolve(param))