Download contracts/lib/openzeppelin-contracts/scripts/remove-ignored-artifacts.js from UTSCybeR/nftbench: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/datasets/UTSCybeR/nftbench/resolve/main/contracts/lib/openzeppelin-contracts/scripts/remove-ignored-artifacts.js
- Command line
-
hf download hf://datasets/UTSCybeR/nftbench/contracts/lib/openzeppelin-contracts/scripts/remove-ignored-artifacts.js
-
curl -L -o remove-ignored-artifacts.js https://huggingface.co/datasets/UTSCybeR/nftbench/resolve/main/contracts/lib/openzeppelin-contracts/scripts/remove-ignored-artifacts.js
1.32 kB
| // This script removes the build artifacts of ignored contracts. | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| const match = require('micromatch'); | |
| function readJSON(path) { | |
| return JSON.parse(fs.readFileSync(path)); | |
| } | |
| const pkgFiles = readJSON('package.json').files; | |
| // Get only negated patterns. | |
| const ignorePatterns = pkgFiles | |
| .filter(pat => pat.startsWith('!')) | |
| // Remove the negation part. Makes micromatch usage more intuitive. | |
| .map(pat => pat.slice(1)); | |
| const ignorePatternsSubtrees = ignorePatterns | |
| // Add **/* to ignore all files contained in the directories. | |
| .concat(ignorePatterns.map(pat => path.join(pat, '**/*'))) | |
| .map(p => p.replace(/^\//, '')); | |
| const artifactsDir = 'contracts/build/contracts'; | |
| const buildinfo = 'artifacts/build-info'; | |
| const filenames = fs.readdirSync(buildinfo); | |
| let n = 0; | |
| for (const filename of filenames) { | |
| const solcOutput = readJSON(path.join(buildinfo, filename)).output; | |
| for (const sourcePath in solcOutput.contracts) { | |
| const ignore = match.any(sourcePath, ignorePatternsSubtrees); | |
| if (ignore) { | |
| for (const contract in solcOutput.contracts[sourcePath]) { | |
| fs.unlinkSync(path.join(artifactsDir, contract + '.json')); | |
| n += 1; | |
| } | |
| } | |
| } | |
| } | |
| console.error(`Removed ${n} mock artifacts`); | |