1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = PandaUSB;
|
7 | function PandaUSB(options) {
|
8 | if (require('is-browser')) {
|
9 | if (options.wifi) {
|
10 | throw new Error('You cannot use wifi mode in the browser.');
|
11 | }
|
12 | var PandaWebUSB = require('./impl/browser').default;
|
13 | return new PandaWebUSB(options, navigator.usb);
|
14 | }
|
15 | if (options.wifi) {
|
16 | var PandaWifi = require('./impl/wifi').default;
|
17 | return new PandaWifi(options);
|
18 | }
|
19 |
|
20 | if (isTestEnv()) {
|
21 | var PandaMock = require('./impl/mock').default;
|
22 | return new PandaMock(options);
|
23 | }
|
24 | if (require('is-node')) {
|
25 | var PandaNodeUSB = require('./impl/node').default;
|
26 | return new PandaNodeUSB(options);
|
27 | }
|
28 | console.log(process.env);
|
29 | throw new Error('pandajs.PandaUSB: Unable to connect to any usb devices, unsupported environment.');
|
30 | }
|
31 |
|
32 | function isTestEnv() {
|
33 | if (process.env.NODE_ENV === 'test') {
|
34 | return true;
|
35 | }
|
36 | if (process.env.npm_lifecycle_event === 'test') {
|
37 | return true;
|
38 | }
|
39 | return false;
|
40 | } |
\ | No newline at end of file |