Skip to content

Commit

Permalink
Merge pull request #178 from ethersphere/add_nonce_count
Browse files Browse the repository at this point in the history
add localhost cleanup
  • Loading branch information
n00b21337 authored Jul 9, 2024
2 parents 15b0708 + 0b217d3 commit b33a57b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion deploy/local/000_deploy_factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
import { DeployFunction } from 'hardhat-deploy/types';
import { rm } from 'fs';
import { promisify } from 'util';
const rmAsync = promisify(rm);

async function deleteDirectory(directoryPath: string) {

Check warning on line 6 in deploy/local/000_deploy_factory.ts

View workflow job for this annotation

GitHub Actions / check

'deleteDirectory' is defined but never used
try {
await rmAsync(directoryPath, { recursive: true, force: true });
console.log(`Deleted directory and all its contents: ${directoryPath}`);
} catch (error) {
console.error('Error deleting directory:', error);
}
}

const func: DeployFunction = async function ({ deployments, getNamedAccounts, ethers }) {
const { deploy, log } = deployments;
Expand All @@ -13,9 +25,13 @@ const func: DeployFunction = async function ({ deployments, getNamedAccounts, et
const code = await ethers.provider.getCode(deployedToken);
let tokenAddress;

// If there's code, then there's a contract deployed
// If there's code, then there's a contract deployed and we are deploying on running hardhat node
if (code !== '0x') {
tokenAddress = deployedToken;

// Do cleanup of previous deployment
const directoryToDelete = 'deployments/localhost/';

Check warning on line 33 in deploy/local/000_deploy_factory.ts

View workflow job for this annotation

GitHub Actions / check

'directoryToDelete' is assigned a value but never used
//await deleteDirectory(directoryToDelete);
} else {
const token = await deploy('TestToken', {
from: deployer,
Expand Down

0 comments on commit b33a57b

Please sign in to comment.