From fac4300321162ce59b3a77ec96cade79414736ed Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Mon, 22 Feb 2021 21:30:27 -0600 Subject: [PATCH] refactor: use assert the way it was intended --- packages/cosmic-swingset/lib/ag-solo/init-basedir.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cosmic-swingset/lib/ag-solo/init-basedir.js b/packages/cosmic-swingset/lib/ag-solo/init-basedir.js index 530fdabb507..638fd15989f 100644 --- a/packages/cosmic-swingset/lib/ag-solo/init-basedir.js +++ b/packages/cosmic-swingset/lib/ag-solo/init-basedir.js @@ -21,12 +21,12 @@ export default function initBasedir( options.wallet = wallet; const here = __dirname; - if ( - fs.existsSync(basedir) && - !fs.existsSync(path.join(basedir, 'ag-cosmos-helper-address')) - ) { - assert.fail(X`${basedir} must not already exist`); - } + // We either need a basedir with an initialised key, or no basedir. + assert( + fs.existsSync(path.join(basedir, 'ag-cosmos-helper-address')) || + !fs.existsSync(basedir), + X`${basedir} must not already exist`, + ); fs.mkdirSync(basedir, { mode: 0o700, recursive: true });