hardhat-contract-sizer
Advanced tools
Comparing version 2.0.0 to 2.0.1
27
index.js
const fs = require('fs'); | ||
const path = require('path'); | ||
const { extendConfig } = require('hardhat/config'); | ||
const colors = require('colors/safe'); | ||
@@ -10,8 +11,14 @@ const Table = require('cli-table3'); | ||
const CONFIG = { | ||
alphaSort: false, | ||
runOnCompile: false, | ||
disambiguatePaths: false, | ||
}; | ||
extendConfig(function (config, userConfig) { | ||
config.contractSizer = Object.assign( | ||
{ | ||
alphaSort: false, | ||
runOnCompile: false, | ||
disambiguatePaths: false, | ||
}, | ||
userConfig.contractSizer | ||
); | ||
}); | ||
const NAME = 'size-contracts'; | ||
@@ -23,4 +30,2 @@ const DESC = 'Output the size of compiled contracts'; | ||
task(NAME, DESC, async function (args, hre) { | ||
let config = Object.assign({}, CONFIG, hre.config.contractSizer); | ||
let files = await hre.artifacts.getArtifactPaths(); | ||
@@ -31,3 +36,3 @@ | ||
if (!config.disambiguatePaths) { | ||
if (!hre.config.contractSizer.disambiguatePaths) { | ||
name = path.basename(name).replace('.json', ''); | ||
@@ -42,3 +47,3 @@ } | ||
if (config.alphaSort) { | ||
if (hre.config.contractSizer.alphaSort) { | ||
contracts.sort((a, b) => a.name.toUpperCase() > b.name.toUpperCase() ? 1 : -1); | ||
@@ -98,9 +103,7 @@ } else { | ||
task(TASK_COMPILE, async function (args, hre, runSuper) { | ||
let config = Object.assign({}, CONFIG, hre.config.contractSizer); | ||
await runSuper(); | ||
if (config.runOnCompile) { | ||
if (hre.config.contractSizer.runOnCompile) { | ||
await hre.run(NAME); | ||
} | ||
}); |
{ | ||
"name": "hardhat-contract-sizer", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"license": "MIT", | ||
@@ -21,2 +21,3 @@ "description": "Output Solidity contract sizes with Hardhat", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"peerDependencies": { | ||
@@ -23,0 +24,0 @@ "hardhat": "^2.0.0" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6673
6
166