Browse Source

Throw when inAppPurchase is used on unsupported platforms

Cheng Zhao 7 years ago
parent
commit
bd271cffb9
2 changed files with 6 additions and 1 deletions
  1. 4 0
      lib/browser/api/in-app-purchase.js
  2. 2 1
      spec/api-in-app-purchase-spec.js

+ 4 - 0
lib/browser/api/in-app-purchase.js

@@ -1,5 +1,9 @@
 'use strict'
 
+if (process.platform !== 'darwin') {
+  throw new Error('The inAppPurchase module can only be used on macOS')
+}
+
 const {EventEmitter} = require('events')
 const {inAppPurchase, InAppPurchase} = process.atomBinding('in_app_purchase')
 

+ 2 - 1
spec/api-in-app-purchase-spec.js

@@ -3,11 +3,12 @@
 const assert = require('assert')
 
 const {remote} = require('electron')
-const {inAppPurchase} = remote
 
 describe('inAppPurchase module', () => {
   if (process.platform !== 'darwin') return
 
+  const {inAppPurchase} = remote
+
   it('canMakePayments() does not throw', () => {
     inAppPurchase.canMakePayments()
   })