From ed7099e65bdf8209e79b6ccabe3b1dd33c8051a7 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 7 Nov 2022 10:17:25 +0100 Subject: [PATCH] check exists before creating files --- apps/etherscan/src/app/views/VerifyView.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/etherscan/src/app/views/VerifyView.tsx b/apps/etherscan/src/app/views/VerifyView.tsx index 4bfda27122..f16c6d8d06 100644 --- a/apps/etherscan/src/app/views/VerifyView.tsx +++ b/apps/etherscan/src/app/views/VerifyView.tsx @@ -92,9 +92,19 @@ export const VerifyView: React.FC = ({ className="btn btn-primary" title="Generate the necessary helpers to start the verification from a TypeScript script" onClick={async () => { - await client.call('fileManager', 'writeFile', 'scripts/etherscan/receiptStatus.ts', receiptGuidScript) - await client.call('fileManager', 'writeFile', 'scripts/etherscan/verify.ts', verifyScript) - client.call('fileManager', 'open', 'scripts/etherscan/verify.ts') + if (!await client.call('fileManager', 'exists' as any, 'scripts/etherscan/receiptStatus.ts')) { + await client.call('fileManager', 'writeFile', 'scripts/etherscan/receiptStatus.ts', receiptGuidScript) + await client.call('fileManager', 'open', 'scripts/etherscan/receiptStatus.ts') + } else { + client.call('notification' as any, 'toast', 'file receiptStatus.ts already present..') + } + + if (!await client.call('fileManager', 'exists' as any, 'scripts/etherscan/verify.ts')) { + await client.call('fileManager', 'writeFile', 'scripts/etherscan/verify.ts', verifyScript) + await client.call('fileManager', 'open', 'scripts/etherscan/verify.ts') + } else { + client.call('notification' as any, 'toast', 'file verify.ts already present..') + } }} > Generate Etherscan helper scripts