Skip to content

Commit

Permalink
ignore missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0neerpat committed May 11, 2024
1 parent 8830d70 commit 6a99564
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
8 changes: 5 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

23 changes: 6 additions & 17 deletions src/copySolidityFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@ import path from 'path';
import fse from 'fs-extra';
import { transformRemappings } from './transformRemappings';

const allowMissingFiles = (srcFile: string) => {
fse
.ensureFile(srcFile)
.then(() => {
return true;
})
.catch(() => {
return false;
});
return false;
};

export const copySolidityFiles = (baseDir: string, filesDir: string, destinationDir: string) => {
const filesDestination = `${destinationDir}/${filesDir}`;
const abiDestination = `${destinationDir}/abi`;
Expand All @@ -33,12 +21,13 @@ export const copySolidityFiles = (baseDir: string, filesDir: string, destination
fse.outputFileSync(path.join(filesDestination, relativeFilePath), relativeFile);
console.log(`Copied ${relativeFilePath} to ${filesDestination}`);

// Copy the abi to the export directory using the same file name
// Copy the abi to the export directory using the same file name. Skip if missing for tests, scripts, etc.
const fileName = filePath.substring(filePath.lastIndexOf('/') + 1, filePath.lastIndexOf('.'));
fse.copySync(`${baseDir}/${fileName}.sol/${fileName}.json`, `${abiDestination}/${fileName}.json`, {
filter: allowMissingFiles,
});
console.log(`Copied ${fileName}.json to ${abiDestination}`);
const fileLocation = `${baseDir}/${fileName}.sol/${fileName}.json`;
if (fse.existsSync(filePath)) {
fse.copySync(fileLocation, `${abiDestination}/${fileName}.json`);
console.log(`Copied ${fileName}.json to ${abiDestination}`);
}
}

console.log(`Copied ${filesPaths.length} interfaces and ABIs`);
Expand Down

0 comments on commit 6a99564

Please sign in to comment.