aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2019-02-08 21:19:47 +0800
committerFabio Berger <me@fabioberger.com>2019-02-08 21:19:47 +0800
commitd01837f42c0aaace6248b1a246b55b929a575562 (patch)
tree42fa43009ccb6736a04feb2a4317918f8a62b95e
parentffd8349889cb27613364a423f1b0f5b87bb26099 (diff)
downloaddexon-0x-contracts-d01837f42c0aaace6248b1a246b55b929a575562.tar
dexon-0x-contracts-d01837f42c0aaace6248b1a246b55b929a575562.tar.gz
dexon-0x-contracts-d01837f42c0aaace6248b1a246b55b929a575562.tar.bz2
dexon-0x-contracts-d01837f42c0aaace6248b1a246b55b929a575562.tar.lz
dexon-0x-contracts-d01837f42c0aaace6248b1a246b55b929a575562.tar.xz
dexon-0x-contracts-d01837f42c0aaace6248b1a246b55b929a575562.tar.zst
dexon-0x-contracts-d01837f42c0aaace6248b1a246b55b929a575562.zip
Allow using Web3Factory in-process Ganache with existing snapshot
-rw-r--r--packages/dev-utils/src/web3_factory.ts7
1 files changed, 5 insertions, 2 deletions
diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts
index 5f8981a46..3fa3c19f7 100644
--- a/packages/dev-utils/src/web3_factory.ts
+++ b/packages/dev-utils/src/web3_factory.ts
@@ -47,8 +47,11 @@ export const web3Factory = {
_.isUndefined(config.shouldThrowErrorsOnGanacheRPCResponse) ||
config.shouldThrowErrorsOnGanacheRPCResponse;
if (!_.isUndefined(config.ganacheDatabasePath)) {
- // Saving the snapshot to a local db. Ganache requires this directory to exist
- fs.mkdirSync(config.ganacheDatabasePath);
+ const doesDatabaseAlreadyExist = fs.existsSync(config.ganacheDatabasePath);
+ if (!doesDatabaseAlreadyExist) {
+ // Working with local DB snapshot. Ganache requires this directory to exist
+ fs.mkdirSync(config.ganacheDatabasePath);
+ }
}
provider.addProvider(
new GanacheSubprovider({