From a8a610cb3428eb8e4abdbaeabb7437b7ba3e4ce5 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 11 Sep 2018 23:00:41 -0700 Subject: [PATCH] chore: remove only on deprecations api spec (#14564) * chore: remove only * add option to ignore missing properties --- lib/browser/api/app.js | 2 +- lib/common/api/deprecate.js | 3 ++- spec/api-deprecations-spec.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/browser/api/app.js b/lib/browser/api/app.js index 291e9cc72ee7..3b8c0e38c88b 100644 --- a/lib/browser/api/app.js +++ b/lib/browser/api/app.js @@ -44,7 +44,7 @@ const nativeFn = app.getAppMetrics app.getAppMetrics = () => { let metrics = nativeFn.call(app) for (const metric of metrics) { - deprecate.removeProperty(metric, 'memory') + deprecate.removeProperty(metric, 'memory', true) } return metrics diff --git a/lib/common/api/deprecate.js b/lib/common/api/deprecate.js index b318b590b368..8275dfe27da6 100644 --- a/lib/common/api/deprecate.js +++ b/lib/common/api/deprecate.js @@ -63,7 +63,7 @@ const deprecate = { this.emit(oldName, ...args) }) }, - removeProperty: (object, deprecated) => { + removeProperty: (object, deprecated, ignoreMissingProps = false) => { let warned = false let warn = () => { if (!(warned || process.noDeprecation)) { @@ -73,6 +73,7 @@ const deprecate = { } if (!(deprecated in object)) { + if (ignoreMissingProps) return throw new Error('Cannot deprecate a property on an object which does not have that property') } diff --git a/spec/api-deprecations-spec.js b/spec/api-deprecations-spec.js index 86b4baf6b276..3afa777a2d02 100644 --- a/spec/api-deprecations-spec.js +++ b/spec/api-deprecations-spec.js @@ -5,7 +5,7 @@ const {deprecations, deprecate, nativeImage} = require('electron') const {expect} = chai chai.use(dirtyChai) -describe.only('deprecations', () => { +describe('deprecations', () => { beforeEach(() => { deprecations.setHandler(null) process.throwDeprecation = true