diff --git a/packages/lib-ethers/.npmignore b/packages/lib-ethers/.npmignore index 016e6d939..2cd20eff1 100644 --- a/packages/lib-ethers/.npmignore +++ b/packages/lib-ethers/.npmignore @@ -1,4 +1,3 @@ /live /accounts.json -/dist/deployments/dev.json /temp diff --git a/packages/lib-ethers/package.json b/packages/lib-ethers/package.json index 806670cf3..7dcf43304 100644 --- a/packages/lib-ethers/package.json +++ b/packages/lib-ethers/package.json @@ -17,6 +17,7 @@ "scripts": { "hardhat": "hardhat", "check-live-version": "ts-node scripts/check-live-version.ts", + "prepublishOnly": "ts-node scripts/delete-dev-deployments.ts", "prepare": "run-s prepare:*", "prepare:deployments": "ts-node scripts/copy-deployments.ts", "prepare:types": "ts-node scripts/generate-types.ts", diff --git a/packages/lib-ethers/scripts/delete-dev-deployments.ts b/packages/lib-ethers/scripts/delete-dev-deployments.ts new file mode 100644 index 000000000..c9dd57b1d --- /dev/null +++ b/packages/lib-ethers/scripts/delete-dev-deployments.ts @@ -0,0 +1,17 @@ +import fs from "fs"; +import path from "path"; + +const deploymentsDir = "deployments"; +const devDeploymentName = "dev.json"; + +const exists = (file: string) => fs.existsSync(file) && fs.lstatSync(file).isFile(); + +const devDeployments = () => + fs + .readdirSync(deploymentsDir, { withFileTypes: true }) + .filter(dirent => dirent.isDirectory() && dirent.name !== "backfill") + .map(deploymentDir => path.join(deploymentsDir, deploymentDir.name, devDeploymentName)) + .concat(path.join(deploymentsDir, devDeploymentName)) + .filter(exists); + +devDeployments().forEach(devDeployment => fs.unlinkSync(devDeployment));