Lesson 7: Hardhat Fund Me module.exports.tags = ["all", "mocks"]. Tags Usage [solved] #214
-
In video 10:48:32 , Patrick types
But don't know what tags are used. I googled and found nobody uses or explains "module.exports.tags". Could someone help? The code is in here const { network } = require("hardhat");
const {
developmentChains,
DECIMALS,
INITIAL_ANSWER,
} = require("../helper-hardhat-config");
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
// const chainId = network.config.chainId;
// if (chainId != )
if (developmentChains.includes(network.name)) {
log("Local network detected! Deploying mocks...");
await deploy("MockV3Aggregator", {
contract: "MockV3Aggregator",
from: deployer,
log: true,
args: [DECIMALS, INITIAL_ANSWER],
});
log("Mocks deployed!");
log("___________________________");
}
};
module.exports.tags = ["all", "mocks"]; |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The tags are to specify what scripts will get ran when mentioning which tag. |
Beta Was this translation helpful? Give feedback.
The tags are to specify what scripts will get ran when mentioning which tag.
For example, the code in your comment is the mock deploy, lets say we only want to run that one specific mock deploy script (in the deploy folder we have: 01-deploy-fund-me.js and just 00-deploy-mocks.js we just wanna deploy 00-deploy-mocks.js).
When we run
yarn hardhat deploy
, by default it runs every script in the deploy folder, so runningyarn hardhat deploy
would run 00-mocks.js and also 01-deploy-fund-me.js.By adding
module.exports.tags = ["all", "mocks"];
in the mock script, it allows us to runyarn hardhat deploy --tags mocks
and our deploy command will only run scripts that have "mocks" in theirmodule.…