From d01837f42c0aaace6248b1a246b55b929a575562 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 8 Feb 2019 13:19:47 +0000 Subject: Allow using Web3Factory in-process Ganache with existing snapshot --- packages/dev-utils/src/web3_factory.ts | 7 +++++-- 1 file 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({ -- cgit v1.2.3 From c794153221af10446e3a9316037451fa1c6dbfdb Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Fri, 8 Feb 2019 13:22:11 +0000 Subject: Add CHANGELOG entry --- packages/dev-utils/CHANGELOG.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/dev-utils/CHANGELOG.json b/packages/dev-utils/CHANGELOG.json index ce6cfede5..cbeb2e74f 100644 --- a/packages/dev-utils/CHANGELOG.json +++ b/packages/dev-utils/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "2.1.0", + "changes": [ + { + "note": "Allow using the Web3Factory in-process Ganache provider with existing DB snapshot", + "pr": 1602 + } + ] + }, { "version": "2.0.2", "changes": [ -- cgit v1.2.3