chore: remove only on deprecations api spec (#14564)
* chore: remove only * add option to ignore missing properties
This commit is contained in:
parent
ebbaa4f89b
commit
a8a610cb34
3 changed files with 4 additions and 3 deletions
|
@ -44,7 +44,7 @@ const nativeFn = app.getAppMetrics
|
||||||
app.getAppMetrics = () => {
|
app.getAppMetrics = () => {
|
||||||
let metrics = nativeFn.call(app)
|
let metrics = nativeFn.call(app)
|
||||||
for (const metric of metrics) {
|
for (const metric of metrics) {
|
||||||
deprecate.removeProperty(metric, 'memory')
|
deprecate.removeProperty(metric, 'memory', true)
|
||||||
}
|
}
|
||||||
|
|
||||||
return metrics
|
return metrics
|
||||||
|
|
|
@ -63,7 +63,7 @@ const deprecate = {
|
||||||
this.emit(oldName, ...args)
|
this.emit(oldName, ...args)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
removeProperty: (object, deprecated) => {
|
removeProperty: (object, deprecated, ignoreMissingProps = false) => {
|
||||||
let warned = false
|
let warned = false
|
||||||
let warn = () => {
|
let warn = () => {
|
||||||
if (!(warned || process.noDeprecation)) {
|
if (!(warned || process.noDeprecation)) {
|
||||||
|
@ -73,6 +73,7 @@ const deprecate = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(deprecated in object)) {
|
if (!(deprecated in object)) {
|
||||||
|
if (ignoreMissingProps) return
|
||||||
throw new Error('Cannot deprecate a property on an object which does not have that property')
|
throw new Error('Cannot deprecate a property on an object which does not have that property')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ const {deprecations, deprecate, nativeImage} = require('electron')
|
||||||
const {expect} = chai
|
const {expect} = chai
|
||||||
chai.use(dirtyChai)
|
chai.use(dirtyChai)
|
||||||
|
|
||||||
describe.only('deprecations', () => {
|
describe('deprecations', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
deprecations.setHandler(null)
|
deprecations.setHandler(null)
|
||||||
process.throwDeprecation = true
|
process.throwDeprecation = true
|
||||||
|
|
Loading…
Reference in a new issue