1 |
|
2 | require("source-map-support/register");
|
3 |
|
4 | const debug = require("debug")("ganache");
|
5 |
|
6 |
|
7 | try {
|
8 |
|
9 | const optionalDependencies = require("./package.json").optionalDependencies;
|
10 | const wrongWeb3 = require("web3/package.json").version !== optionalDependencies.web3;
|
11 | const wrongEthereumJs =
|
12 | require("ethereumjs-wallet/package.json").version !== optionalDependencies["ethereumjs-wallet"];
|
13 | if (wrongWeb3 || wrongEthereumJs) {
|
14 | useBundled();
|
15 | } else {
|
16 | module.exports = require("./public-exports.js");
|
17 | module.exports._webpacked = false;
|
18 | debug("Optional dependencies installed; exporting ganache-core with native optional dependencies.");
|
19 | }
|
20 | } catch (nativeError) {
|
21 | debug(nativeError);
|
22 |
|
23 |
|
24 | useBundled();
|
25 | }
|
26 |
|
27 | function useBundled() {
|
28 | try {
|
29 | module.exports = require("./build/ganache.core.node.js");
|
30 | module.exports._webpacked = true;
|
31 | debug("Optional dependencies not installed; exporting ganache-core from `./build` directory.");
|
32 | } catch (webpackError) {
|
33 | debug("ganache-core could not be exported; optional dependencies nor webpack build available for export.");
|
34 | throw webpackError;
|
35 | }
|
36 | }
|