cl args to set check path

This commit is contained in:
Aleksandr S 2021-09-05 11:32:18 +03:00
parent cf504594be
commit 6c5460fac2
3 changed files with 15 additions and 5 deletions

View File

@ -54,3 +54,9 @@ Few things to consider while writing the connector:
If you can't find something you're looking for or have any questions, ask them at our developers community on [Discord](https://discord.gg/83vvrnY) or simply send an [Email](mailto:info@instadapp.io).
## Check run
use
`npm run check`
to check `connectors` directory. Use `connector=$` argument to check specific connector:
`npm run check connector=contracts/mainnet/common`

View File

@ -6,6 +6,7 @@
"scripts": {
"test": "hardhat test",
"coverage": "./node_modules/.bin/solidity-coverage",
"check": "node status-checks/huskyCheck.js",
"check-husky": "node status-checks/huskyCheck.js",
"build-contracts": "sol-merger \"./contracts/connectors/mock.sol\" ./contracts/build"
},

View File

@ -3,13 +3,11 @@ const path = require('path')
const forbiddenStrings = ['selfdestruct']
const getConnectorsList = async () => {
const getConnectorsList = async (connectorsRootsDirs) => {
try {
const connectors = []
const connectorsRootsDirs = ['mainnet', 'polygon']
for (let index = 0; index < connectorsRootsDirs.length; index++) {
const root = `contracts/${connectorsRootsDirs[index]}/connectors`
const dirs = [root]
const dirs = [connectorsRootsDirs[index]]
while (dirs.length) {
const currentDir = dirs.pop()
const subs = fs.readdirSync(currentDir, { withFileTypes: true })
@ -326,9 +324,14 @@ const checkHeadComments = async (connector) => {
async function checkMain () {
try {
const connectorsRootsDirsDefault = ['mainnet', 'polygon'].map(v=> `contracts/${v}/connectors`)
const customPathArg = process.argv.find(a => a.startsWith('connector='))
const connectorsRootsDirs = customPathArg
? [customPathArg.slice(10)]
: connectorsRootsDirsDefault
const errors = []
const warnings = []
const connectors = await getConnectorsList()
const connectors = await getConnectorsList(connectorsRootsDirs)
for (let index = 0; index < connectors.length; index++) {
const { forbiddenErrors, code } = await checkForbidden(connectors[index].path)
connectors[index].code = code