Skip to content

Commit

Permalink
fix: Error Handling and Improvements in File Deletion Process
Browse files Browse the repository at this point in the history
  • Loading branch information
ursulabauer authored Dec 21, 2024
1 parent ba8b5cf commit d637497
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions scripts/remove-ignored-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const fs = require('fs');
const path = require('path');
const match = require('micromatch');

function readJSON(path) {
return JSON.parse(fs.readFileSync(path));
function readJSON(filePath) {
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
}

const pkgFiles = readJSON('package.json').files;
Expand Down Expand Up @@ -35,11 +35,16 @@ for (const filename of filenames) {
const ignore = match.any(sourcePath, ignorePatternsSubtrees);
if (ignore) {
for (const contract in solcOutput.contracts[sourcePath]) {
fs.unlinkSync(path.join(artifactsDir, contract + '.json'));
n += 1;
const filePath = path.join(artifactsDir, contract + '.json');
try {
fs.unlinkSync(filePath);
n += 1;
} catch (error) {
console.error(`Error removing file: ${filePath}`);
}
}
}
}
}

console.error(`Removed ${n} mock artifacts`);
console.error(`Removed ${n} build artifacts`);

0 comments on commit d637497

Please sign in to comment.